@Html.TextBoxFor(model => model.IsActive, new { readonly= "readonly" })
This is just fine for text box. However, if you try to do same for the checkbox
then try using this if you are using it:
@Html.CheckBoxFor(model => model.IsActive, new { onclick = "return false" })
But don't use disable
, because disable always sends the default value false
to the server - either it was in the checked or unchecked state. And the readonly
does not work for checkbox and radio button
. readonly
only works for text
fields.