lundi 16 février 2015

How to modify hidden autogenerated checkbox of `CheckBoxFor` in MVC4?

As many have stated the following Html helper of the MVC generates a hidden checkbox, but i cannot find nowhere how to modify the class of the autogenerated checkbox input. The problem is that somehow the hidden checkbox interferes with the normal one and destroys the appearance of the css. For that reason i need to update the hidden checkbox to include the same css class as the normal checkbox. Is it possible to do that preferably with the MVC?


Server Html helper:



@Html.CheckBoxFor(m => m.IsActive, new { @class="px"})
<span class="lbl">Active user</span>


Generated html:



<input class="px" data-val="true" data-val-required="This field is required." id="IsActive" name="IsActive" type="checkbox" value="true">
<input name="IsActive" type="hidden" value="false">
<span class="lbl">Active user</span>




Aucun commentaire:

Enregistrer un commentaire