title: ASP.NET event lifecycle for inherited user controls
body: <p>Please forgive the psuedo-code, but it's a simple question:</p>
  
  <p>I create a user control (myControlBase : UserControl) with a textbox (id = "txtbox") in it's markup.  In it's codebehind I write a method SayHello(string s){ txtbox.Text = s; }.  </p>
  
  <p>I create another user control that extends myControlBase (myControl : myControlBase).  In page_load of this child control, I call SayHello("hello"); and receive a runtime error telling me that txtbox is null (it hasn't been created yet obviously).</p>
  
  <p>How then, can I inherit from a user control and have my child controls access the base control's markup?  I've tried to read up on event lifecycle for these controls, but I guess I'm not getting it.</p>
  
  <p>Any ideas?</p>
  
  <p>-edit-</p>
  
  <p>I'm sorry, it is ASP.Net.  If this code makes it any clearer, then I must have done a pretty poor job of describing the issue.</p>
  
  <p>txtBox is an ASP:Textbox Control that exists in the markup of myControlBase.</p>
  
  <pre><code>public partial class myControlBase : System.Web.UI.UserControl
  {
    protected void SayHello(string s){
      txtBox.Text = s;
    }
  }
  
  public partial class myControl: myControlBase
  {
      protected void Page_Load(object sender, EventArgs e)
      {
        SayHello("hello");
      }
  }
  </code></pre>
  
  <p>This would fail at SayHello("hello"); because txtBox returned Null.</p>