I have a checkbox and button:
@using(Html.BeginForm())
{
Include completed
Will Post a value of "on"
or "off"
.
This WONT bind to a boolean,
To receive a boolean value you can use HTML Helper Checkbox Like
@Html.CheckBox("showAll")
Update:
If checked the html helper will post back
"true,false"
and if unchecked as"false"
You can have this workaround as
bool MyBoolValue= Convert.ToBoolean(collection["showAll"].Split(',')[0]);
This is because the Html helpers class adds an extra hidden
field to save the state of the checkbox