LloydMc
asked on
Programatically added user control's IsPostback property
Hello all,
We are programatically loading user controls at run time using a place holder control. The IsPostback property of these programatically loaded user controls are always true in the UC's Page_Load, Page_PreRender and Init events. In this case I need to populate a drop down list on the UC, but I only want to do this once when it's initially loaded. Is there a way to detect an initial load for a dynamically added user control?
We are programatically loading user controls at run time using a place holder control. The IsPostback property of these programatically loaded user controls are always true in the UC's Page_Load, Page_PreRender and Init events. In this case I need to populate a drop down list on the UC, but I only want to do this once when it's initially loaded. Is there a way to detect an initial load for a dynamically added user control?
In B.aspx.cs - the user control
should be
In B.ascx.cs - the user control
...Although now that I re-read the Q, I'm not entirely convinced I anwered it... : p
should be
In B.ascx.cs - the user control
...Although now that I re-read the Q, I'm not entirely convinced I anwered it... : p
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In A.aspx:
protected override bool OnBubbleEvent(object source, EventArgs args)
{
B B1 = source as B;
if (B1 != null)
{
// do what ever yo want
return true; // to stop further bubbling of event
}
return base.OnBubbleEvent (source, args);
}
In B.aspx.cs - the user control:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
RaiseBubbleEvent(this, e);
}
}
...That just might do it : )