使用复选框提交表单在asp.net mvc的 [英] Using Checkbox submit form in asp.net mvc
本文介绍了使用复选框提交表单在asp.net mvc的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面的图像,我怎么能检查到复选框来调用Update方法控制器
http://i.stack.imgur.com/5RmbK.jpg
> HttpPost]
>公众的ActionResult更新(INT ID)
> {
> //在DB code更新状态
> }
解决方案
试试这个(剃刀语法):
//一个复选框
@ Html.CheckBox(chkName,假的,新的{的onclick =this.form.submit();})//如果使用强类型模型属性
@ Html.CheckBoxFor(型号=> model.chkName,新{的onclick =this.form.submit();})
The following the image, how i can to call Update method in controller by checking into checkbox http://i.stack.imgur.com/5RmbK.jpg
>[HttpPost]
>public ActionResult Update(int id)
>{
> //code update status in db
> }
解决方案
Try this (Razor syntax):
//for a checkbox
@Html.CheckBox("chkName",false, new {onclick="this.form.submit();"})
//if using strongly typed model property
@Html.CheckBoxFor(model=> model.chkName, new {onclick="this.form.submit();"})
这篇关于使用复选框提交表单在asp.net mvc的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文