I want to Enable or Disable a textbox based on the value (Model.CompanyNameEnabled).
The below code is not working. Please rectify.
@{
string displayMode = (Model.CompanyNameEnabled) ? "" : "disabled = disabled";
@Html.TextBox("CompanyName", "", new { displayMode })
}
You should pass htmlAttribute as anonymous object, with property names = html attribute names, property values = attribute values. Your mistake was that you were passing string instead of name=value pair