title: Get Textbox Value from Masterpage using c#
body: <p>I have a search textbox situated on a masterpage like so:</p>
  
  <pre><code>&lt;asp:TextBox ID="frmSearch" runat="server" CssClass="searchbox"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:LinkButton ID="searchGo" PostBackUrl="search.aspx"  runat="server"&gt;GO&lt;/asp:LinkButton&gt;
  </code></pre>
  
  <p>The code behind for the search page has the following to pick up the textbox value (snippet):</p>
  
  <pre><code>if (PreviousPage != null &amp;&amp; PreviousPage.IsCrossPagePostBack)
          {
              Page previousPage = PreviousPage;
              TextBox tbSearch = (TextBox)PreviousPage.Master.FindControl("frmSearch");
              searchValue.Text = tbSearch.Text;
  
              //more code here...
          }
  </code></pre>
  
  <p>All works great. BUT not if you enter a value whilst actually on search.aspx, which obviously isn't a previous page. How can I get round this dead end I've put myself in?</p>