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

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

    In case if you have to apply your custom class you can use

      @Html.TextBoxFor(m => m.Birthday,   new Dictionary() { {"readonly", "true"}, {"class", "commonField"} } )
    

    Where are

    commonField is CSS class

    and Birthday could be string field that you probably can use to keep jQuery Datapicker date :)

    
    

    That's a real life example.

提交回复
热议问题