title: ASP.NET expose controls to other class
body: <p>I have been battling this for some time and I need some guidance.</p>
  
  <p>I'm coding in ASP.NET 4.0 WEBFORMS.</p>
  
  <p><strong>Question is: How to expose a textbox, Label or any other control to another class.</strong> </p>
  
  <p>I have a webform (see below). </p>
  
  <pre><code>public partial class WebForm1 : System.Web.UI.Page
  {
  
  }
  </code></pre>
  
  <p><strong>This is then referenced and sent to another class.</strong></p>
  
  <pre><code>public class SearchInitializer
  {
      private WebForm1 _webform1;
  
      public SearchInitializer(WebForm1 Webform1)
      {
          _webform1 = Webform1;
      }
  
      public void ChewSettings()
      {
  
          _webform1 //can't find any control in here?!
      }
  
  }
  </code></pre>
  
  <p>First I thought of <strong>creating a public property</strong> which I thought I could access from the reference I sent to the new class.. But nooo!</p>
  
  <pre><code>public partial class WebForm1 : System.Web.UI.Page
  {
     public string KeywordBox1 
      {
          get {return txt_keyword.Text;}
          set {txt_keyword.Text = value;}
      }
  
  }
  </code></pre>
  
  <p>The I tried to <strong>inherit the Webform into the other class</strong>. Making the the property available but no luck there.</p>
  
  <pre><code>public class SearchInitializer : Webform1
  {
      private WebForm1 _webform1;
  
      public SearchInitializer(WebForm1 Webform1)
      {
          _webform1 = Webform1;
      }
  
      public void ChewSettings()
      {
  
          _webform1 //can't find any control in here?!
      }
  
  }
  </code></pre>
  
  <p>Okay an abstract class migth be of use here, inheriting everything. But I think I got that wrong to. I have events and static classes, so they can talk with the page. But I really would like not to use a static class as a container to save all the info in my controls.
  So these are the examples I have tried and they all failed. So this is me basicly trying to expand what I know ;) Thanks for reading!!
  Why have they failed and how should I do it?</p>
  
  <p>EDIT AS REQUESTED!</p>
  
  <pre><code>public partial class WebForm1 : System.Web.UI.Page
  {
  
       protected void btn_click(object sender, EventArgs e)
       {
           SearchInitializer searchIni = new SearchInitializer(this);
       }
  
  }
  </code></pre>