I have the following inside my asp.net mvc web application :-
<div><span class="f">Data Center Name</span> @Html.EditorFor(model => model.Switch.TMSRack.DataCenter.Name, new { disabled = "disabled" })</div>
but the field will not be disabled ,, can anyone adivce please? THanks
@Html.EditorFor()
does not have an overload to support htmlAttributes. You could try @Html.TextBoxFor()
@Html.TextBoxFor(model => model.propertyName, new {disabled= "disabled" })
If you are using system key words such as class
in htmlAttributes please add @
before the attribute name.
Ex:
@Html.TextBoxFor(model => model.propertyName, new {@class = "disabledClass" })