title: Controls added in the designer are null during Page_Load
body: <p>All of the names below are generic and not the actual names used.</p>
  
  <p>I have a custom UserControl with a Panel that contains a a couple Labels, both .aspx controls.</p>
  
  <p>.aspx:</p>
  
  <pre><code>&lt;asp:Panel runat="server"&gt;
      &lt;asp:Label ID="label1" runat="server"&gt;
      &lt;/asp:Label&gt;
  &lt;/asp:Panel&gt;
  &lt;asp:Panel runat="server"&gt;
      &lt;asp:Label ID="label2" runat="server"&gt;
      &lt;/asp:Label&gt;
  &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>Codebehind:</p>
  
  <pre><code>private readonly Object object;
  protected void Page_Load(object sender, EventArgs e)
  {
      // These are the lines that are failing
      // label1 and label2 are null
      label1.Text = object.Value1;
      label2.Text = object.Value2;
  }
  public ObjectRow(Object objectToDisplay)
  {
      object = objectToDisplay;
  }
  </code></pre>
  
  <p>On another page, in the code behind, I create a new instance of the custom user control.  </p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      Usercontrol control = new UserControl(object);
      Controls.Add(control);
  }
  </code></pre>
  
  <p>The user control takes the parameter and attempts to set the labels based off of the object passed in.  </p>
  
  <p>The labels that it tries to assign the values to are however, null.  </p>
  
  <p>Is this an ASP.net lifecycle issue that I'm not understanding?  My understanding based on the <a href="http://msdn.microsoft.com/en-us/library/ms178472.aspx" rel="noreferrer">Microsoft ASP.net lifecycle page</a> was that page controls were available after the Page_Initialization.</p>
  
  <p>What is the proper way to do this?  Is there a better way?</p>
  
  <p>EDIT:  From below I've tried using Page.LoadControl.  </p>
  
  <p>If I load the control based off of the string representation of the path and file name it prohibits passing a parameter.  I can circumvent this by adding a method that allows me to set the object.  While this works it feels hackish.  I would prefer to be able to pass the value to the constructor if this is possible.</p>
  
  <p>Using the overloaded method gives the same result as loading only the code behind, the labels that are being assigned are null.</p>
  
  <p>EDIT: Apparently the overloaded method not instantiating the child controls added on the .ascx file is "by design".  I found this in the comments at <a href="http://msdn.microsoft.com/en-us/library/ewtd66a0.aspx" rel="noreferrer">Microsoft's page for Page.LoadControl(type, object[])</a></p>