所以,我有一个操作方法是这样的:MVC表单提交多个参数
public ViewResult CareerSearch()
{
CareerSearchModel model = GetCareerSearchModel();
return View("Search", model);
}
在视图中,我手动从模特属性之一创建一个复选框列表。 ,它的输出最终看起来是这样的:
<input id="location51438342" type="checkbox" checked="True" value="2" name="locations">
<label for="location51438342">Austin</label>
<input id="location14609737" type="checkbox" checked="True" value="9" name="locations">
<label for="location14609737">Dallas</label>
<input id="location25198218" type="checkbox" checked="True" value="11" name="locations">
<label for="location25198218">Houston</label>
因此,在处理表单POST操作方法,我想给模型和复选框整数数组的引用。但是,当我通过以下操作方法执行时,“模型”为空:
[HttpPost]
public ViewResult CareerSearch(CareerSearchModel model, int[] locations)
{
//omitted for brevity
}
我在这里丢失了什么?我如何获得对我的模型和复选框值的数组的引用?
模型是否有名为“位置”的属性,您试图绑定?还是你指的是你在示例中没有显示的其他属性? – Quesi 2011-04-22 18:57:12