title: Textbox lose value after postback
body: <p>I have a group of text box that allows the user to automatically compute the gross amount. The computation is working but when the page post back all the text box value is gone. Any help would be much appreciated! Thank you!</p>
  
  <p>Please see below my codes.</p>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>$(document).ready(function () {
              Number.prototype.formatMoney = function (c, d, t) {
                  var n = this,
                  c = isNaN(c = Math.abs(c)) ? 2 : c,
                  d = d == undefined ? "." : d,
                  t = t == undefined ? "," : t,
                  s = n &lt; 0 ? "-" : "",
                  i = String(parseInt(n = Math.abs(Number(n) || 0).toFixed(c))),
                  j = (j = i.length) &gt; 3 ? j % 3 : 0;
                  return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
              };
  
          });
  
          $(document).ready(function () {
              $(this).keyup(function () {
  
                  $("input[name='txtbx_less']").each(function (index) {
                      var txtbx_gross = $("input[name='ctl00$MainContent$txtbx_gross']").eq(index).val().replace(/,/g, "");
                      var txtbx_less = parseFloat(txtbx_gross) * 0.15;
  
                      if (!isNaN(txtbx_less)) {
                          $("input[name='ctl00$MainContent$txtbx_less']").eq(index).val(txtbx_less.formatMoney());
                      }
  
                  });
  
                  $("input[name='txtbx_net']").each(function (index) {
                      var txtbx_gross = $("input[name='txtbx_ctl00$MainContent$txtbx_grossgross']").eq(index).val().replace(/,/g, "");
                      var txtbx_less = $("input[name='ctl00$MainContent$txtbx_less']").eq(index).val().replace(/,/g, "");
                      var txtbx_net = parseFloat(txtbx_gross) - parseFloat(txtbx_less);
  
                      if (!isNaN(txtbx_net)) {
                          $("input[name='ctl00$MainContent$txtbx_net']").eq(index).val(txtbx_net.formatMoney());
                      }
  
                  });
  
                  $("input[name='ctl00$MainContent$txtbx_add']").each(function (index) {
                      var txtbx_net = $("input[name='ctl00$MainContent$txtbx_net']").eq(index).val().replace(/,/g, "");
                      var txtbx_add = parseFloat(txtbx_net) * 0.12;
  
  
                      if (!isNaN(txtbx_add)) {
                          $("input[name='ctl00$MainContent$txtbx_add']").eq(index).val(txtbx_add.formatMoney());
  
                      }
  
                  });
  
                  $("input[name='txtbx_billed']").each(function (index) {
                      var txtbx_net = $("input[name='txtbx_net']").eq(index).val().replace(/,/g, "");
                      var txtbx_add = $("input[name='txtbx_add']").eq(index).val().replace(/,/g, "");
                      var txtbx_billed = parseFloat(txtbx_net) + parseFloat(txtbx_add);
  
                      if (!isNaN(txtbx_billed)) {
                          $("input[name='txtbx_billed']").eq(index).val(txtbx_billed.toFixed(2));
                      }
                  });
  
  
                  $("input[name='txtbx_add1']").each(function (index) {
                      var txtbx_net1 = $("input[name='txtbx_net1']").eq(index).val().replace(/,/g, "");
                      var txtbx_add1 = parseFloat(txtbx_net1) * 0.12;
  
  
                      if (!isNaN(txtbx_add1)) {
                          $("input[name='txtbx_add1']").eq(index).val(txtbx_add1.formatMoney());
                      }
  
                  });
  
                  $("input[name='txtbx_billed1']").each(function (index) {
                      var txtbx_net1 = $("input[name='txtbx_net1']").eq(index).val().replace(/,/g, "");
                      var txtbx_add1 = $("input[name='txtbx_add1']").eq(index).val().replace(/,/g, "");
                      var txtbx_billed1 = parseFloat(txtbx_net1) + parseFloat(txtbx_add1);
  
                      if (!isNaN(txtbx_billed1)) {
                          $("input[name='txtbx_billed1']").eq(index).val(txtbx_billed1.formatMoney());
                      }
                  });
  
  
  
              });
  
  
          }); 
  </code></pre>
  
  <p><strong>Front-end</strong></p>
  
  <pre><code>    &lt;table class = "billcomp"&gt;
          &lt;tr&gt;
          &lt;td class = "prebiltd"&gt;GROSS AMOUNT :&lt;/td&gt;
          &lt;td class = "prebiltd"&gt;
          &lt;dx:ASPxTextBox ID="txtbx_gross" runat="server" Width="170px" Theme="Material"&gt;
          &lt;MaskSettings Mask="&lt;0..99999999g&gt;.&lt;00..99&gt;" AllowMouseWheel="false"/&gt;
          &lt;/dx:ASPxTextBox&gt;
          &lt;/td&gt;
         &lt;/tr&gt;
  
         &lt;tr&gt;
         &lt;td class = "prebiltd"&gt;LESS: 15% ASF :&lt;/td&gt;
         &lt;td class = "prebiltd"&gt;
         &lt;dx:ASPxTextBox ID="txtbx_less" runat="server" Width="170px" Theme="Material"&gt;
         &lt;MaskSettings Mask="&lt;0..99999g&gt;.&lt;00..99&gt;" AllowMouseWheel="false"/&gt;
         &lt;/dx:ASPxTextBox&gt;
         &lt;/td&gt;
         &lt;/tr&gt;
  
         &lt;tr&gt;
         &lt;td class = "prebiltd"&gt;NET AMOUNT :&lt;/td&gt;
         &lt;td class = "prebiltd"&gt;
         &lt;dx:ASPxTextBox ID="txtbx_net" runat="server" Width="170px" Theme="Material"&gt;
         &lt;MaskSettings Mask="&lt;0..99999g&gt;.&lt;00..99&gt;" AllowMouseWheel="false"/&gt;
         &lt;/dx:ASPxTextBox&gt;
         &lt;/td&gt;
         &lt;/tr&gt;
  
         &lt;tr&gt;
         &lt;td&gt;&lt;/td&gt;
         &lt;td&gt;
         &lt;asp:CheckBox ID="chckbox_nonvat" runat="server" Text="NON-VAT"&gt;&lt;/asp:CheckBox&gt;
         &lt;/td&gt;
         &lt;/tr&gt;
  
     &lt;tr&gt;
     &lt;td class = "prebiltd"&gt;ADD 12% VAT :&lt;/td&gt;
     &lt;td class = "prebiltd"&gt;
     &lt;dx:ASPxTextBox ID="txtbx_add" runat="server" Width="170px" Theme="Material" ClientInstanceName="txtbx_add"&gt;
     &lt;MaskSettings Mask="&lt;0..99999g&gt;.&lt;00..99&gt;" AllowMouseWheel="false"/&gt;
     &lt;/dx:ASPxTextBox&gt;
     &lt;/td&gt;
     &lt;/tr&gt;
  
     &lt;tr&gt;
     &lt;td class = "prebiltd"&gt;BILLED AMOUNT :&lt;/td&gt;
     &lt;td class = "prebiltd"&gt;
     &lt;dx:ASPxTextBox ID="txtbx_billed" runat="server" Width="170px" Theme="Material"&gt;
     &lt;MaskSettings Mask="&lt;0..99999g&gt;.&lt;00..99&gt;" AllowMouseWheel="false"/&gt;
     &lt;/dx:ASPxTextBox&gt;
     &lt;/td&gt;
     &lt;/tr&gt;
  
     &lt;/table&gt;
  </code></pre>
  
  <p><strong>Back end codes</strong></p>
  
  <pre><code>Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
   txtbx_gross.ClientSideEvents.Init = "function(s,e){   s.GetInputElement().name='txtbx_gross';   }"
          txtbx_less.ClientSideEvents.Init = "function(s,e){   s.GetInputElement().name='txtbx_less';   }"
          txtbx_net.ClientSideEvents.Init = "function(s,e){   s.GetInputElement().name='txtbx_net';   }"
          txtbx_add.ClientSideEvents.Init = "function(s,e){   s.GetInputElement().name='txtbx_add';   }"
          txtbx_billed.ClientSideEvents.Init = "function(s,e){   s.GetInputElement().name='txtbx_billed';   }"
  
          txtbx_net1.ClientSideEvents.Init = "function(s,e){   s.GetInputElement().name='txtbx_net1';   }"
          txtbx_add1.ClientSideEvents.Init = "function(s,e){   s.GetInputElement().name='txtbx_add1';   }"
          txtbx_billed1.ClientSideEvents.Init = "function(s,e){   s.GetInputElement().name='txtbx_billed1';   }"
  End Sub
  </code></pre>