samedi 27 janvier 2018

Why is this CheckBox not checked?

I have an MVC ASP.Net Core website I'm writing and I've got a checkbox. I've spent hours thinking my binding was somehow wrong because I can save the value and it goes into the database but the view to the user always shows an unchecked checkbox. I finally had a look at the rendered HTML in Chrome Dev tools and this the checkbox:

    <input data-val="true" data-val-required="The Show Profile Picture field is required." id="ShowProfilePic" name="ShowProfilePic" type="checkbox" value="true">

The value is true like it is in the database but in the browser the check box is unticked. The value it's looking at in the Model and ViewModel are both bool. Any ideas?




Aucun commentaire:

Enregistrer un commentaire