title: ASP.NET Textbox value coming empty on server side when set from JQuery
body: <p>I am setting asp.net textbox's value from javascript and then trying to access the same from code behind, but its coming empty. I am totally clueless why it is happening that way.</p>
  
  <p>As suggested somewhere, I tried to change ASP.NET textbox control to input HTML control with runat server, things worked like a charm. But I am desperate to know why the hell asp.net textbox behave that way.</p>
  
  <p>Below are the code blocks:</p>
  
  <p><strong>MarkUP</strong>:</p>
  
  <pre><code>&lt;div class="ingredient-block"&gt;
      &lt;span&gt;
         &lt;asp:Localize ID="lblIngrQty" runat="server" Text="&lt;%$ Resources:Resources, lblIngrQty %&gt;"&gt;&lt;/asp:Localize&gt;&lt;/span&gt;&lt;br&gt;
         &lt;asp:TextBox ID="txtQty" CssClass="txtBack" Width="50px" runat="server" TabIndex="10" onchange="fnVerifyQuantityValue(this);" onfocus="fnShowQtyOnFocus(this);" onblur="fnHideKeywordWindow(this);"&gt;&lt;/asp:TextBox&gt;
         &lt;actAjax:TextBoxWatermarkExtender ID="TeterxtBox5_TextBoxWamarkExtender" runat="server"
         WatermarkText="&lt;%$ Resources:Resources, lblIngrQty %&gt;" Enabled="True" WatermarkCssClass="watermark1" TargetControlID="txtQty"&gt;
         &lt;/actAjax:TextBoxWatermarkExtender&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>function fnShowQtyOnFocus(oQty) {
          var hiddenQtyKw = fnUnEscapeXMLValue($("#&lt;%=hdnQtyCommonKw.ClientID%&gt;").val());
  
          if (hiddenQtyKw.length &gt; 1) {
              var xmlCommonQty = $.parseXML(hiddenQtyKw);
              $XMLCommonQTY = $(xmlCommonQty);
              var keywordCollection = $XMLCommonQTY.find('Name');
  
              var ul = document.createElement("ul");
  
              for (index = 0; index &lt; keywordCollection.length; index++) {
                  var li = document.createElement("li");
                  li.innerHTML = keywordCollection[index].textContent;
  
                  li.onclick = function () {
                      if ($("#" + oQty.id).val() == "Qty" || $("#" + oQty.id).val() == "Mängd") {
                          $("#" + oQty.id).val("");
                          $("#" + oQty.id).val(this.innerHTML);
                      }
                      else {
                          $("#" + oQty.id).val($("#" + oQty.id).val() + this.innerHTML);
                      }
                  };
  
                  $(ul).append(li);
              }
  
              $(".showKeyword").html("");
              $(".showKeyword").show();
              $(".showKeyword").append(ul);
  
              var offset = $("#" + oQty.id).offset();
              var posY = offset.top - $(window).scrollTop();
              var posX = offset.left - $(window).scrollLeft();
  
              $(".showKeyword").css("top", posY - 20);
              $(".showKeyword").css("left", posX);
          }
      }
  </code></pre>
  
  <p>Don't wonder about the JS function. It is creating an unordered list with suppose 5 li elements, adding that ul element to a div and showing the div above the txtQty control. Then user will click on any of the 5 elements and then I copy the li value to txtQty control. See the onclick handler.</p>
  
  <p>So, now when I go to server by a button postback, I don't see any value in txtQty.</p>
  
  <p>Please help.</p>
  
  <p>Thanks</p>