我在我的应用程序中使用Jquery添加了多个TextBoxes,然后在我想要的代码后台文件中可以通过Request.formname访问这些值。我想迭代这些文本框并读取用户输入的任何文本的值,这样我就可以将其存储在数据库中。你知道如何在数据库中保存这些文本框的值吗?我使用的是asp.net 2.0
$(document).ready(function () {
var counter = 2;
$("#addButton").click(function () {
if (counter > 10) {
alert("Only 10 textboxes allow");
return false;
}
var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.html('<table><tr><td><input type="text" name="textbox' + counter +
'" id="textbox' + counter + '" value="" ></td><td><input type="text" name="textbox' + counter +
'" id="textbox' + counter + '" value="" ></td><td><input type="text" name="textbox' + counter +
'" id="textbox' + counter + '" value="" ></td></tr></table>');
newTextBoxDiv.appendTo("#TextBoxesGroup");
return false;
counter++;
});
});
发布于 2013-03-05 15:52:25
foreach (string key in Request.Form.AllKeys)
{
if (key.StartsWith("textbox"))
{
string value = Request.Form[key];
//Do some stuff...
}
}
https://stackoverflow.com/questions/15121674
复制