<body> <form id="form1" runat="server"> <p> <input id="Button1" type="button" value="button" onclick="addbtn()" /><asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button" /> </p> <div id="test"></div> </form> <script type="text/javascript"> function addbtn() { var div = document.getElementById("test"); var btn = document.createElement("input"); btn.type = "text"; btn.name = "content"; div.appendChild(btn); } </script> </body> protected void Button2_Click(object sender, EventArgs e) { for (int i = 0; i < Request.Form["content"].Count(); i++) { Response.Write(Request.Form["content"][i].ToString()+"<br/>"); } }
我用JS动态创建文本框,然后在后台获取动态区域的值,现在用Request.Form["content"]获到是所有字符串连在一起的值,如何获得每个文本框的值呢?