This seems ridicouous but can you only return true/false from an MVC checkbox? I remember back in the day (in classic asp) it was perfectly valid to return a value from a ticked checkbox but Microsoft appears to of decided that checkboxes should only contain true/false value.
So if you add the following:
@Html.CheckBox("PropertyTypes", true, new {@value="A"})
I would expect my form POST to contain Property=A, what I end up with isProperty=A&Property=true which then breaks the model so I get a null in the property rather than the string I wanted.
On investigation it turns out this is because microsoft adds an extra input for so I get a false if I don't want to check the input...gee thanks a lot......:/
<input id="PropertyTypes" type="checkbox" value="Hotel" name="PropertyTypes" data-val-youmustselectatleastone="You must select at least one Property Type" data-val="true" checked="checked">
<input type="hidden" value="false" name="PropertyTypes">
WHY!
I could just code in an input myself just using flat HTML but then I loose all my unobtrusive validation.
any ideas on how to get around this stupidity?
Ps the number of checkboxes is dynamic so adding a property for each value isn't going to cut it.