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

后端 未结 15 1531
爱一瞬间的悲伤
爱一瞬间的悲伤 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:57

    To make it read only

    @Html.TextBoxFor(m=> m.Total, new {@class ="form-control", @readonly="true"})
    

    To diable

    @Html.TextBoxFor(m=> m.Total, new {@class ="form-control", @disabled="true"})
    

提交回复
热议问题