在Controller里可以用FormCollection去取得View上控件的值,不过Button类型的取不到。
例子如下:
public ActionResult Allot(FormCollection _formCollection)
{
string[] str = _formCollection["functions"].ToString().Split(',');
int s = int.Parse(_formCollection["authorityid"]);
}
前台代码
<span>权限名称:@k
<input type="hidden" value="@id" name="authorityid" />
</span>
<br />
<span>功能项:</span><br />
@foreach (var item in ViewBag.functions as IEnumerable<MYJPS.Models.Function>)
{
<input type="checkbox" value="@item.FunctionID" name="functions" />@item.Name<br />
}
<input type="submit" value="确认" />