Welcome to weblogs.com.pk Sign in | Join | Help

Dotnetnuke :: Multiple ascx as single control and passing data in between

When working with portal frameworks like Sharepoint or Dotnetnuke; your user interface might have multiple ASCX files that work together. Instead of making all the ASCX files compliant to portal framework; better approach is that you create one “container” control compliant with the portal framework and load your user controls as per UI flow.

Problem comes when you want that on some event (row selected in grid, button click etc) in one ASCX; you load the other ASCX and at the same time pass some values. People tend to adopt techniques like passing data using query string, session or cookies. It might work at time of development; but chances are when your “thing” is deployed it might not work; due to certain assumption that you might have taken while implementing the approach.

Here is one technique that works pretty well…

  1. Implement the eventarg wrapper class for the data that you need to pass
  2. Add an event in the source control using the custom eventarg class; invoke this event when you need to load other control and pass data
  3. In the second control; implement the property to receive the data
  4. In container; subscribe the event when loading the control
  5. In container; on the event; get the value from the eventarg and set it to the secondly loaded control using its property

A sample app is shown in the figures below for reference


Custom EventArgs Class


Event in source


Property in destination


Container code, showing how to load differenet ascx and passing data using event/property
Published Thursday, June 29, 2006 4:57 PM by khurram
Filed under:

Comments

No Comments

New Comments to this post are disabled