Reputation: 2470
Here is my dummy model:
class Customer {
string Name;
// View Model part
bool IsDisabled;
}
Here is my view:
@using (Html.BeginForm(actionName, controllerName))
{
@Html.TextBoxFor( c => c.Name, new { disabled = ***) })
<input type="submit" value="Submit" />
}
So the question is: How can i bind the 'isDisabled' property of my viewmodel to the 'disabled' attribute of my textbox? i.e. What should stand in the place of '*' ?
Upvotes: 1
Views: 367
Reputation: 22054
@Html.TextBoxFor(c => c.Name, Model.IsDisabled ? new { disabled = "disabled" } : null)
Upvotes: 2