【发布时间】:2012-02-17 00:29:10
【问题描述】:
我的 Html.CheckBox() View 控件返回 null 到 Controller 是否有原因? 似乎无法弄清楚这一点,希望有任何帮助!
查看:
@{ Html.BeginForm("ActionName", "ControllerName", FormMethod.Get); }
Enter Text: @Html.TextBox("Code", string.Empty, new { id = "Code" })
<input type="submit" value="GO" />
<span style="padding-left:20px; font-size:14px" >@Html.CheckBox("exactMatch", false, new { id = "textmatches" })
 Text exact match</span>
@{ Html.EndForm(); }
提交表单时调用的控制器:
public ActionResult ActionName(string code,bool boxChecked)
{
return View(ServiceCallGoesHere(code.Trim(),boxChecked));
}
我不知道为什么我的复选框状态没有传递给控制器。为什么控制器中的 boxChecked 参数总是 = null ?我该如何解决这个问题?
提前谢谢你!
【问题讨论】:
标签: c# asp.net-mvc view html-helper