How to create a readonly text using html helper in asp.net mvc?

后端 未结 6 1951
陌清茗
陌清茗 2020-12-15 17:54

I want to disable a textbox in the view. So I use following code:

<%= Html.TextBox(\"ID\", Model.ID, new { readonly=\"true\" })%>

or

6条回答
  •  隐瞒了意图╮
    2020-12-15 17:59

    Keep in mind a disabled TextBox will not be submitted with a html form, but a readonly TextBox will.

    MVC3 documentation shows the signature as Html.TextBox(string name, object value, object htmlAttributes) used above.

提交回复
热议问题