When you are using a checkbox on your view in MVC then that checkbox also add a extra hidden filed for same name and when you go submit then you will get hidden filed value of check box like
<input id="notcfm" name="notcfm" onchange="$(this).closest('form').submit();" value="true" type="checkbox">
>input value="false" name="notcfm" type="hidden"></input>
When you are going to submit this form using check box then you will get two value one is by hidden field of check box and another is check box value because Check box is not updating before submission and both have different values.
Now check box and hidden filed have same name then a single request variable has both values comma separate like "true,false" but first value always for checkbox and second value for hidden filed so you can split this and get check box value.
create your View like:
<h2>Index</h2>
@using(Ajax.BeginForm("Index", "City",
new
{
page = 1,
},
new AjaxOptions
{
HttpMethod = "POST",
UpdateTargetId = "divupdate",
InsertionMode = InsertionMode.Replace
}))
{
@Html.CheckBox("notcfm", new { name = "notcfm", onChange = "$(this).closest('form').submit();" })
<div id="divupdate"></div>
}
and after that you get values of checkbox in post action method in controller:
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(string page,FormCollection form)
{
bool isNotCfm = Convert.ToBoolean(form["notcfm"].Split(',')[0]);
return View();
}
you can know more way about how can pass values from view to controller:
Getting Data From View to Controller in MVC[
^]