I have the following tag with a Html.TextBoxFor expression and I want the contents to be read only, is this possible?
<%= Html.TextBoxFor(m => Model.E
In fact the answer of Brain Mains is almost correct:
@Html.TextBoxFor(model => model.RIF, new { value = @Model.RIF, @readonly = true })
You can also disabled TextBoxFor
@Html.TextBoxFor(x=>x.day, null, new { @class = "form-control success" ,@disabled="disabled" })
The following snippet worked for me.
@Html.TextBoxFor(m => m.Crown, new { id = "", @style = "padding-left:5px", @readonly = "true" })
This work for me...
@Html.TextBoxFor(model => model.RIF, new { value = @Model.RIF, @readonly = "readonly" })
By setting readonly attribute to either true or false is not going to work in most browsers, I have done it as below, when the mode of the page is "reload", I've not included "readonly" attribute.
@if(Model.Mode.Equals("edit")){
@Html.TextAreaFor(model => Model.Content.Data, new { id = "modEditor", @readonly = moduleEditModel.Content.ReadOnly, @style = "width:99%; height:360px;" })
}
@if (Model.Mode.Equals("reload")){
@Html.TextAreaFor(model => Model.Content.Data, new { id = "modEditor", @style = "width:99%; height:360px;" })}
<%= Html.TextBoxFor(m => Model.Events.Subscribed[i].Action, new { @readonly = true })%>