title: How to get the values from dynamically generated html textboxes in asp.net
body: <p>I want to fetch the values from dynamically created html textboxes in  my aspx page. Now first I want to check if the textbox exists or not. If exists then I want to fetch values from these texboxes. Here is the code which I am using for creating textboxes dynamically </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var counter = 2;
      $(document).ready(function () {
  
          $("#addButton").click(function () {
              if (counter &gt; 3) {
                  alert("Limit Exceeds");
                  return false;
              }
              var $wrap = $('#TextBoxesGroup');
              var dynamichtml = '&lt;div id="div' + counter + '"&gt;&lt;div class="mcity"&gt;&lt;label&gt; Leaving from&lt;/label&gt;&lt;input type="text" name="textbox' + counter + '" id="textbox' + counter + '" class="auto"/&gt;  &lt;/div&gt;&lt;div class="mcity"&gt; &lt;label&gt; Going to&lt;/label&gt;  &lt;input type="text" name="textbox' + counter + '" id="textbox' + counter + 1 + '" class="auto"/&gt; &lt;/div&gt;&lt;div class="mcity"&gt; &lt;label&gt; Going to&lt;/label&gt;  &lt;input type="text" name="textbox' + counter + '" id="textbox' + counter + 11 + '" class="auto"/&gt; &lt;/div&gt;';
              $wrap.append(dynamichtml);
              counter++;
          });
  
          $("#removeButton").click(function () {
              if (counter == 1) {
                  alert("No more textbox to remove");
                  return false;
              }
  
              counter--;
              $("#TextBoxesGroup").find("#div"+ counter).remove();
            //  $("#TextBoxesGroup").find("#textbox" + counter+1).remove();
  
  
          });
    $(".auto").live("focus", function () {
  
                    $(this).autocomplete({
  
                        source: function (request, response) {
                            var textval = request.term; // $(this).val();
                            $.ajax({
                                type: "POST",
                                contentType: "application/json; charset=utf-8",
                                url: "Home.aspx/GetAutoCompleteData",
                                data: "{'code':'" + textval + "'}",
                                dataType: "json",
                                success: function (data) {
                                    response(data.d);
                                },
                                error: function (result) {
                                    alert("Error");
                                }
                            });
                        }
                    });
                });
            });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>This code is generating textboxes generating and I am fetching data from my database using json autocomplete process.After this I am trying to send the information to another page using javascript the code that I write for this is below </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
        $(function () {
            $("#btnPost").bind("click", function () {
                //Create a Form
                var $form = $("&lt;form/&gt;").attr("id", "data_form")
                              .attr("action", "Complete.aspx")
                              .attr("method", "post");
                $("body").append($form);
  
                //Append the values to be send
                AddParameter($form, "txtleft", $("#txtSearchleft").val());
                AddParameter($form, "txtright", $("#txtSearchright").val());
  
                //Send the Form
                $form[0].submit();
            });
        });
        function AddParameter(form, name, value) {
            var $input = $("&lt;input /&gt;").attr("type", "hidden")
                                  .attr("name", name)
                                  .attr("value", value);
            form.append($input);
        }
      &lt;/script&gt;
  </code></pre>
  
  <p>This work fine for textboxes which placed default in my page. But for the textboxes that generate dynamically after these textboxes I dnt know how to send values of those textboxes to my next page </p>
  
  <p>Javascript and asp.net experts please help me to resolve this </p>
  
  <p>Thanks</p>