Reputation: 63
Its a quick question.
@Html.TextBoxFor(model => model.VIN, string.IsNullOrEmpty(Model.VIN) ? new { @class = "required Vin" } : new { @disabled = "disabled" })
I get the error that Type of expression can not be determined because there is no implicit conversion anonymous type #1 and anonymous type #2.
Is there a way to conditionally disable text box?
Upvotes: 3
Views: 3749
Reputation: 3237
Try something like
@Html.TextBoxFor(model => model.VIN, string.IsNullOrEmpty(Model.VIN) ? new { @class = "required Vin" } : (object)new { disabled = "disabled" })
Upvotes: 5