Suppose I have a user control MyControl.ascx, and I put it in the Default.aspx like this:
<uc1:MyControl id="MyControl" runat="server">
Now in the code-behind of Default.aspx I do this:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
MyControl.Visible = false;
}
The problem is that even I do not render MyControl, it is still being initialised and goes through the entire ASCX life cycle (OnLoad, etc). Is there a way to prevent the control from being initialised at all?
Thanks.