Making A Text Field Read Only
I am using the code below to make the text entry read only but this does not become read only any idea why this could be @Html.EditorFor(model => model.UserName, new { Readonly
Solution 1:
Why cont you use
@Html.EditorFor(model => model.UserName, new { @readonly = true});
or you can use like
@Html.EditorFor(model => model.UserName, new { @readonly = "readonly"});
Solution 2:
try textboxfor
@Html.TextBoxFor(model => model.UserName, new { @readonly = true})
Solution 3:
The HtmlHelper EditorFor
do not have overloads that take HTML attributes.
Instead of EditorFor
go with TextBoxFor
@Html.TextBoxFor(model => model.UserName, new { disabled = "disabled", @readonly = "readonly"})
hope it helps
Post a Comment for "Making A Text Field Read Only"