title: Get input textbox values in the codebehind from the client
body: <p>I have created a JavaScript button that will add 4 textboxes and a fileupload control on the clients browser.  They can add as many of these as they need too.  </p>
  
  <p>My issue now is on the submit button how can I loop through these controls to get the values to put in my database?</p>
  
  <p>JavaScript</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var rownum = 1;
  
  function AddRow() {
  
    var div = document.createElement("div")
  
    var divid = "dv" + rownum
    div.setAttribute("ID", divid)
    rownum++
  
    var txtFName = document.createElement("input")
    txtFName.setAttribute("ID", "txtFName" + rownum)
    txtFName.placeholder = "First Name";
    txtFName.style.width = "190px";
    rownum++
    var txtLName = document.createElement("input")
    txtLName.setAttribute("ID", "txtLName" + rownum)
    txtLName.placeholder = "Last Name";
    txtLName.style.width = "190px";
    rownum++
    var txtEmail = document.createElement("input")
    txtEmail.setAttribute("ID", "txtEmail" + rownum)
    txtEmail.placeholder = "Email";
    txtEmail.style.width = "289px";
    rownum++
    var txtInst = document.createElement("input")
    txtInst.setAttribute("ID", "txtAge" + rownum)
    txtInst.placeholder = "Age";
    txtInst.style.width = "100px";
    rownum++
    var _upload = document.createElement("input")
    _upload.setAttribute("type", "file")
    _upload.setAttribute("ID", "upload" + rownum)
    _upload.setAttribute("runat", "server")
    _upload.setAttribute("name", "uploads" + rownum)      
    _upload.style.width = "610px";
    rownum++
  
    var btnRemove = document.createElement("input")
    btnRemove.type = "button";      
    btnRemove.setAttribute("onclick", "return RemoveDv('" + divid + "');");
    btnRemove.innerText = "Remove";
    rownum++
  
    var _pdiv = document.getElementById("ParentDiv")
  
    div.appendChild(document.createElement('br'))      
    div.appendChild(txtFName)      
    div.appendChild(txtLName)      
    div.appendChild(txtEmail)
    div.appendChild(document.createElement('br'))
    div.appendChild(txtInst)
    div.appendChild(document.createElement('br'))
    div.appendChild(_upload)
    div.appendChild(document.createElement('br'))
    div.appendChild(btnRemove)
    div.appendChild(document.createElement('br'))      
    _pdiv.appendChild(div)
  }
  
  function RemoveDv(obj) {
    var p = document.getElementById("ParentDiv")
    var chld = document.getElementById(obj)
    p.removeChild(chld)
  }
  </code></pre>
  
  <p></p>
  
  <p>ASP.aspx</p>
  
  <pre><code>&lt;table width="100%" class="pagetext_10"&gt;
  &lt;tr&gt;
      &lt;td colspan="10"&gt;
        &lt;input type="button" onclick="AddRow(); 
             return false;" value="Add Employees" /&gt;&amp;nbsp;
        &lt;div id="ParentDiv" style="width:100%;"&gt;
        &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;          
      &lt;/td&gt;
     &lt;/tr&gt;    
  &lt;/table&gt;
  </code></pre>