My ViewModel has a property of selected and selectable. Both are boolean. I would like my view to have a checkbox that is enabled when selectable is true and disabled when selectable is false. What is the proper razor syntax to accomplish this ?
I tried the code below on a list of items in a table. Every row comes back with a disabled checkbox regardless of selectable value.
@Html.CheckBoxFor(modelItem => item.Selected, new { @disabled = !item.Selectable })
See Question&Answers more detail:os