Can I set text box to readonly when using Html.TextBoxFor?

后端 未结 15 1570
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 18:07

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         


        
15条回答
  •  误落风尘
    2020-12-08 18:47

    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;" })}
    

提交回复
热议问题