I have a masterpage with an update panel:
<asp:UpdatePanel ID="UpdatePanel" runat="server" ChildrenAsTriggers="true" EnableViewState="False"
UpdateMode="Conditional">
<ContentTemplate>
<div id="mainContent">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
Then I have Default.aspx page which uses the masterpage file:
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
<asp:PlaceHolder ID="plhCurrentItem" runat="server"></asp:PlaceHolder>
</asp:Content>
I programmatically load usercontrols into the placeholder with id plhCurrentItem.
The problem is when I click a button in the usercontrol, no event fires. The usercontrol just disappears and the updatepanel is left blank.
What am I doing wrong?
Update
Code used to add usercontrols. The LoadControls method is called from the Page_load event.
Control ctlCurrentItem = null;
public string currentControl
{
get { return ((string)Session["currentControl"]); }
set { Session["currentControl"] = value; }
}
public void LoadControls()
{
switch (currentControl)
{
case "Home":
ctlCurrentItem = Page.LoadControl("~/pages/Home.ascx");
ctlCurrentItem.ID = "Home";
break;
case "Resume":
ctlCurrentItem = Page.LoadControl("~/pages/Resume.ascx");
ctlCurrentItem.ID = "Resume";
break;
case "Projects":
ctlCurrentItem = Page.LoadControl("~/pages/Projects.ascx");
ctlCurrentItem.ID = "Projects";
break;
case "Contact":
ctlCurrentItem = Page.LoadControl("~/pages/Contact.ascx");
ctlCurrentItem.ID = "Contact";
break;
default:
return;
}
plhCurrentItem.Controls.Clear();
plhCurrentItem.Controls.Add(ctlCurrentItem);
}