title: Textbox.text always returns empty string in code behind c#
body: <p>Well, I'm trying to do a simple command: get the text from TextBox. I've searched for that, but every answer failed for me.</p>
  
  <p>In my code aspx:</p>
  
  <pre><code>&lt;form id="form1" runat="server" method="post"&gt;
      &lt;div class="form"&gt;
  
          &lt;div class="form-search ngen-search-form"&gt;
  
              &lt;span id="search-trigger" class="form-search-submit"&gt;
                  &lt;img src="Imagens/Lupa_Icon 2.png" id="lupa"/&gt;
              &lt;/span&gt;
  
              &lt;asp:TextBox ID="txtBoxSearch" runat="server" CssClass="form-search-input" placeholder="Pesquise..." ViewStateMode="Enabled"/&gt;
  
          &lt;/div&gt;
  
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I have a Javascript function that verifies what key my client pressed:</p>
  
  <pre><code>$(document).keypress(function(e) {
          if(e.which == 13){
  
              if( document.getElementById("txtBoxSearch").value == "" ) return true;
  
              else {
  
                  &lt;% setSearch(); %&gt;
  
                  document.getElementById("testeArv").innerHTML='&lt;%=search.ToString()%&gt;';
  
                  return false;
  
              }
  
          }// First if
  
  });
  </code></pre>
  
  <p>And finally, my function <em>setSearch()</em> in code behind is:</p>
  
  <pre><code>public void setSearch( )
  {
      if( !Page.IsPostBack ) {
  
          search = txtBoxSearch.Text;
  
      }
  }
  </code></pre>