mardi 3 février 2015

Checkbox is checked but Model is still false

I have the following model:



public class TaskViewModel{
//other properties are omitted for brevity
IsUnderControl{get;set;}
}


On the other hand I have these two DOM elements that I manually bind to the model property:



<input type="checkbox" name="IsUnderControl" value="true"/>
<input type="hidden" name="IsUnderControl" value="false" />


Now, after submitting, the value of IsUnderControl is false even if the checkbox is checked.


*Note: When I inspect the checkbox I see that there's no checked="checked" among the element checkbox atributes.





Aucun commentaire:

Enregistrer un commentaire