vendredi 5 février 2016

Setting value of CheckBoxFor

I am trying to set the checkbox value (true/false) to a field. I can get the value, but cannot set it.

Within my Model I have:

public bool ReceiveNewsletter { get; set; }

In my View I have:

@Html.CheckBoxFor(u => u.ReceiveNewsletter, new { @class = "checkbox", type = "checkbox" })

When I load the application, the checkbox is unchecked because ReceiveNewsletter is false however, when I check the checkbox and click submit, it doesn't set the value to true

Does anyone know what I am doing wrong?




Aucun commentaire:

Enregistrer un commentaire