I have a checkbox like this:
<%= Html.CheckBoxFor(x => x.IsSendingQualitySurvey) %>/>
when checking the checkbox and submitting, I get the typical 2 form values:
IsSendingQualitySurvey: true
IsSendingQualitySurvey: false
This is perfectly valid for the way the mvc modelbinder handles checkboxes.
Then in the controller action:
[HttpPost]
public ActionResult Edit(Guid id, TicketEditViewModel ticketEditViewModel)
ticketEditViewModel.IsSendingQualitySurvey (a normal bool) is always false.
I don't have any custom model binders and it works elsewhere. Strangely enough I've had the same problem in another view quite a while ago, where I had to create the input manually, looks like this:
<input type="checkbox" value="true" name="<%=Html.NameFor(x => x.IsRequestingVisit) %>" id="<%=Html.NameFor(x => x.IsRequestingVisit) %>" />
This worked, but when I copied the exact same over to the other view, the value is still always false.
Wheres the catch?
Thanks.