Reputation: 11794
how do you make @Html.CheckBoxFor
invisible with use of the htmlAttributes?
I tried:
@Html.CheckBoxFor(modelItem => modelItem.DeleteEnabled, new {visible= @modelItem.Visible})
Upvotes: 3
Views: 4916
Reputation: 9755
You can try like this:
@Html.CheckBoxFor(modelItem => modelItem.DeleteEnabled,
new { style = modelItem.Visible ?
string.empty :
"display:none"})
or if you do not need it at the page source at all, nor even hidden then use @if
for example:
@if(modelItem.Visible)
{
@Html.CheckBoxFor(modelItem => modelItem.DeleteEnabled)
}
Upvotes: 2