本文介绍了如何将当前表单的值传递给控制器​​mvc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想将notcfm值传递为1如果复选框选中其他明智的0 查看 @ using(Ajax.BeginForm(Index,City, new { page = 1, } , new AjaxOptions { HttpMethod =GET, UpdateTargetId =divupdate, InsertionMode = InsertionMode.Replace })) { @ Html.CheckBox(chkoptn,false,new {name =notcfm,onChange =$(this).closest('form')。submit();})} 控制器 public ActionResult索引( int ?page, int ?notcfm) { } i我得到 notcfm为null 解决方案 (this).closest('form')。submit();}) 因为帮助器的语法复选框是: - @ Html.CheckBox(Nameofthe checkbox,false,new {,,,,,,}); i希望这对你有用,如果没有请发表评论。 I want to pass notcfm value as 1 if checkbox checked other wise 0View@using(Ajax.BeginForm("Index", "City", new { page = 1, }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "divupdate", InsertionMode = InsertionMode.Replace })){@Html.CheckBox("chkoptn", false, new { name = "notcfm", onChange = "$(this).closest('form').submit();" })}Controllerpublic ActionResult Index(int? page, int? notcfm) {}i am gettingnotcfm is null 解决方案 这篇关于如何将当前表单的值传递给控制器​​mvc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-09 10:57