title: Why dynamically created user controls disappear when controls are not doing full postbacks?
body: <p>Based on my current understandings, when you have an UpdatePanel control there is no full postback. Therefore if I dynamically add custom user controls and they have UpdatePanels that are updated in their code they shouldnt disappear from the page they are loaded into, right? Apparently not. I made a simple project to test and still my dynamic controls disappear when clicked even though they should not be triggering a full postback. I have an aspx page that loads the controls: </p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TESTmultipleScriptManagerControls.aspx.cs" Inherits="myPlayground.TESTmultipleScriptManagerControls" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
  
      &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
      &lt;/asp:ScriptManager&gt;
  
      &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
      &lt;ContentTemplate&gt;
      &lt;asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /&gt;
  
      &lt;asp:PlaceHolder ID="PlaceHolder1" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
      &lt;/ContentTemplate&gt;
      &lt;/asp:UpdatePanel&gt;
  
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>With the following code behind:</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
      {
  
          TESTcontrol1 temp = LoadControl("TESTcontrol1.ascx") as TESTcontrol1;
          PlaceHolder1.Controls.Add(temp);
          TESTcontrol1 temp2 = LoadControl("TESTcontrol1.ascx") as TESTcontrol1;
          PlaceHolder1.Controls.Add(temp2);
  
      }
  </code></pre>
  
  <p>And a simple user control:</p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TESTcontrol1.ascx.cs" Inherits="myPlayground.TESTcontrol1" %&gt;
  &lt;asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"&gt;
  &lt;/asp:ScriptManagerProxy&gt;
  &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
  
  &lt;ContentTemplate&gt;
  &lt;asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /&gt;
  &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
  &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>With the following code behind:</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
      {
          Label1.Text = System.DateTime.Now.ToString();
      }
  </code></pre>
  
  <p>Any ideas on why the controls are disappearing even though there shouldnt be a postback triggering?</p>