Weird this one.
On my .NET MVC 4 project I've added a file on App_Code who contains this method:
@helper CheckBox(string name, bool isChecked = false, string className = "") {
<div class="checkboxHolder">
<input id="@name" name="@name" type="hidden" value="@isChecked") />
<i class="@className checkboxBts fa @((isChecked) ? "fa-check-square-o" : "fa-square-o")" data-checkbox-associated="@name"></i>
</div>
}
I'm using it to style checkboxes using font-awesome, so my app checkboxes are made of an input type hidden who stores a boolean value and an icon to give feedback to users.
Weird thing is, on executing when isChecked == false, the hidden returned by this method is like:
<input id="myCheckboxId" name="myCheckboxId" type="hidden" />
There is no value at all, when I try to save it to the model an exception is thrown saying that model cannot be saved.
I've fixed it changing the method to use:
<input id="@name" name="@name" type="hidden" @((isChecked) ? "value=true" : "value=false") />
Which is working fine. However, I wonder if anyone know what could be happening on the original output.
Thank you all.