title: ASP.NET issue when removing Control on Page Load
body: <p>I have following Index.aspx web form:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="ProblematicWebApplication.Index" %&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;asp:Label ID="dummyLabel" runat="server" Text="This is dummy label." /&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;asp:DropDownList ID="intDropDownList" runat="server"/&gt;
          &lt;br /&gt;
          &lt;asp:Button Text="Submit" OnClick="OnSubmitClicked" runat="server"/&gt;
          &lt;br /&gt;
          Selected value: &lt;asp:Label ID="selectedValueLabel" runat="server" /&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And following code behind Index.aspx.cs file:</p>
  
  <pre><code>using System;
  using System.Linq;
  
  namespace ProblematicWebApplication
  {
      public partial class Index : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!this.IsPostBack)
              {
                  this.intDropDownList.DataSource = Enumerable.Range(0, 11).ToArray();
                  this.intDropDownList.DataBind();
              }
  
              if (this.Request["remove-dummy"] != null)
                  this.Controls.Remove(this.dummyLabel);
          }
  
          protected void OnSubmitClicked(object sender, EventArgs e)
          {
              this.selectedValueLabel.Text = this.intDropDownList.SelectedValue;
          }
      }
  }
  </code></pre>
  
  <p>When I run my application with no remove-dummy parameter in query string and select some value from intDropDownList and click Submit button, selected value is accordingly presented in selectedValueLabel.</p>
  
  <p>But if I run my application with remove-dummy=1 parameter in query string, dummyLabel gets removed. Now when I select some value from intDropDownList and click Submit button, selected value is not correctly written to selectedValueLabel and all items from intDropDownList are removed.</p>
  
  <p>Can someone explain it to me why this is happening?
  Why removing unrelated dummyLabel control has influence on intDropDownList control?</p>