retriving values from the dynamically added textboxes in asp.net
<p>i am asp.net beginner,I am developing one website in which i want to add or remove text boxes dynamically as required (on click event of hyperlink). And on submit button i want to count the number of text boxes created,retrieve their values and dump this data in database.</p>

<p>I have used following java script to add the textboxes--</p>

<pre><code>function addTxtBx()
{
         var txtBxHolder = document.getElementById('MyDiv');
         var txtdiv = document.createElement('div');
         txtdiv.setAttribute("id", "MyD1");
         var newTxtBx1 = document.createElement('input');

         newTxtBx1.type = 'text';


         newTxtBx1.setAttribute("id", "MyText1");



         txtdiv.appendChild(newTxtBx1);


         txtBxHolder.appendChild(txtdiv);

}

function removeTxtBx() 
{
         var allTxtBxs = document.getElementById('MyDiv').getElementsByTagName('div');
         if (allTxtBxs.length == 0) 
         {
             alert('there are no text boxes to remove');
         }
         else 
         {
             document.getElementById('MyDiv').removeChild(allTxtBxs[allTxtBxs.length -     1]);

         } 
}
</code></pre>

<p>And to access the values used following code on button click</p>

<pre><code>TextBox textbox = (TextBox)Page.FindControl("MyText1"); 
string val = textbox.Text;
</code></pre>

<p>But it is not working.
Am i doing something wrong????
Thanks in advance..</p>
