I have a model which has a field
[DisplayName("Receive occasional email notifications about new services or features")]
public bool ReceiveEmail { get; set; }
In my view I want a checkbox which will come checked by default.
I tried this:
<%:Html.CheckBoxFor(m => m.registerModel.ReceiveEmail, new { @checked = "checked" })%>
But did not work…
Any help will be appreciated.
Thanks
Arnab
The proper way to do this is to set your view model property in the controller action rendering this view:
Now all you need in your strongly typed view is:
and the checkbox will be automatically checked.