Note that there are some explanatory texts on larger screens.

plurals
  1. POUsercontrol postback not working in updatepanel
    primarykey
    data
    text
    <p>I have a masterpage with an update panel:</p> <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel" runat="server" ChildrenAsTriggers="true" EnableViewState="False" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;div id="mainContent"&gt; &lt;asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;/div&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>Then I have Default.aspx page which uses the masterpage file:</p> <pre><code>&lt;asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1"&gt; &lt;asp:PlaceHolder ID="plhCurrentItem" runat="server"&gt;&lt;/asp:PlaceHolder&gt; &lt;/asp:Content&gt; </code></pre> <p>I programmatically load usercontrols into the placeholder with id plhCurrentItem.</p> <p>The problem is when I click a button in the usercontrol, no event fires. The usercontrol just disappears and the updatepanel is left blank.</p> <p>What am I doing wrong?</p> <hr> <p><strong>Update</strong></p> <p>Code used to add usercontrols. The LoadControls method is called from the Page_load event.</p> <pre><code> 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); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload