title: Request.Form giving extra values from Dynamic Textboxes
body: <p>i am working with dynamic TextBoxes and then Getting their Values in code behind file. I am creating these boxes using Javascript. my asp.net page code is </p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
  
          $(document).ready(function () {
  
              var counter = 1;
  
              $("#addButton").click(function () {
  
                  if (counter &gt; 10) {
                      alert("Only 10 textboxes allow");
                      return false;
                  }
  
                  var newTextBoxDiv = $(document.createElement('div'))
                       .attr("id", 'TextBoxDiv' + counter);
  
  
                  newTextBoxDiv.html('&lt;input type="text" name="textbox' + counter +
                        '" id="textbox' + counter + '" value="" &gt;');
  
                  newTextBoxDiv.appendTo("#TextBoxesGroup");
                  counter++;
                  return false;
              });
          });
      &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;form id="form2" runat="server"&gt;
  
          &lt;h1&gt;jQuery add / remove textbox example&lt;/h1&gt;
  
          &lt;asp:TextBox runat="server" ID="txt1" type='text' name="textname" /&gt;
          &lt;asp:Panel runat="server" ID='TextBoxesGroup'&gt;
          &lt;/asp:Panel&gt;
          &lt;asp:LinkButton ID="addButton" runat="server"&gt;Add TextBox&lt;/asp:LinkButton&gt;
  
          &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /&gt;
      &lt;/form&gt;
      &lt;asp:Label ID="Label1" runat="server" Text=""&gt;&lt;/asp:Label&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>i have one Textbox shown on the page, which should shows only one values when no dynamic Textbox is created. My C# code is </p>
  
  <pre><code> protected void Button1_Click(object sender, EventArgs e)
      {
          string name = txt1.Text + ",";
          if (TextBoxesGroup.Controls.Count  &gt; 0)
          {           
              for (int i = 1; i &lt;= TextBoxesGroup.Controls.Count; i++)
              {
                  name += Request.Form["textbox" + i] + ",";
              }    
          }
  
          Label1.Text = name;
      }
  </code></pre>
  
  <p>on asp:button click it should display all the values separated by (,). but it is only showing top 2 values, one of which is asp:Textbox and second is dynamic Textbox,, i want the values of all the Textboxes created dynamically, and when no dynamic textbox is added it should only show the value from asp:textBox... Thanks in Advance</p>