MVC 如何取得View中的值传到Controller

在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="确认" />

posted @ 2012-08-30 11:11  Buu  阅读(1026)  评论(0编辑  收藏  举报