I have a function to load a user control, it looks like this:
private void AddPopupControlToPage()
{
WidgetConfiguration popupControl = new WidgetConfiguration();
popupControl = (WidgetConfiguration)LoadControl("~/Docking/Widgets/WidgetConfiguration.ascx");
popupControl.ID = "PopupControlInput1";
g_PopupControlId = popupControl.ClientID;
popupControl.Attributes.Add("width", "150px");
Form.Controls.Add(popupControl);
}
I have drop down that allows me to change the page layout based on what template is selected. I should be able to press call the popup control from any template(page). Based on what I’ve read here http://msdn.microsoft.com/en-us/library/ms178472.aspx I should be able to load my control in the Page_PreInit event, however the form is not loaded at that point and I get a null reference error. Any ideas on how/where I should load my popup control and keep it available to any selected page?
you should load a control always overriding the CreateChildControls method
soomething like