title: How to set asp.net 's label 's text using javascript and get setted value on server side
body: <p>I  have two questions about javascript and asp.net , the result i want is : make a label same change when textbox keypress, here are what i do :</p>
  
  <p>in asp.net page:</p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
  
      &lt;asp:TextBox ID="TextBox1" runat="server" onkeypress="okpress();"&gt;&lt;/asp:TextBox&gt;
      &lt;br /&gt;
      &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
      &lt;br /&gt;
      &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClick="test1" /&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and this is my script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function okpress() {
          //alert('Your keypress on TextBox1.');
          var v1 = document.getElementById("Label1");
          v1.innerHTML = document.getElementById("TextBox1").value;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>when i test the result , i find label1 's text do change when textbox1 keypress , but it is strange that label1 's text always lack one char with textbox1 , that is to say , if i type "abcd" in  textbox1, label1 only display "ab".</p>
  
  <p>another question is about the button , when i write this code in .cs file:</p>
  
  <pre><code>    protected void test1(object sender, EventArgs e)
      {
          string s1 = Label1.Text;
          return;
      }
  </code></pre>
  
  <p>and add a breakpoint at "return" ,  i find no matter whatever i type in textbox1 , the variable s1 always is "Label1" </p>
  
  <p>i think this two question maybe easy to experience one , but i just can not solve it, thanks for any helps.</p>