我有一个表单,我通过jQuery动态添加控件.在将表单发布回服务器时,我需要访问这些控件(文本框)中的值.我确信这是一个微不足道的问题,但我无法理解它.
任何帮助都会大大减少.
向页面添加多个控件时,请为它们指定相同的name属性,以便在操作中执行以下操作:
public ActionResult MyAction(string[] items)
{
// items will contain all the values in the text boxes
return View();
}
Run Code Online (Sandbox Code Playgroud)
所以你的HTML就像这样
<input type="text" name="items" />
<input type="text" name="items" />
<input type="text" name="items" />
<input type="text" name="items" />
<input type="text" name="items" />
<input type="text" name="items" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1170 次 |
| 最近记录: |