title: ASP.Net - How do I add a HiddenField from another WebControl and maintain it?
body: <p>I've got a WebControl that I want to dynamically add a HiddenField from.</p>
  
  <p>I've tried the following example: <a href="https://stackoverflow.com/questions/1028905/asp-net-webcontrol-page-adding-controls-like-textbox-dynamically">Click here</a>, but that doesn't work due to the fact this.Page.Form is null in the Page Init event. </p>
  
  <p>I've tried the following, but the value is never maintained:</p>
  
  <pre><code>HiddenField hd_IsDirty = new HiddenField();
  
  protected override void OnInit(EventArgs e)
  {
  
      this.Controls.Add(hd_IsDirty);
      hd_IsDirty.ID = "hd_IsDirty";
  
      base.OnInit(e);
  
  }
  </code></pre>