所以,我有一個操作方法是這樣的: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