How to set the re开发者_运维知识库adonly attribute to HTML Textbox helper class.
<%= Html.TextBox("Email", "abc@example.com", new { @class = "required email" } )%>
Appreciate your response
<%= Html.TextBox("Email", "abc@example.com", new { @class = "required email", @readonly="readonly" }) %>
<%= Html.TextBox("Email", "abc@example.com", new { @class = "required email", @readonly = "readonly" } )%>
For better performance, use the following :
ASPX:
<%= Html.TextBox("Email", ew Dictionary<string, object> { {"class","required email"}, {"readonly","readonly"} } %>
Razor:
@Html.TextBoxFor(model => model.Email, new Dictionary<string, object> { { "class", "required email" }, {"readonly","readonly"} })
@Html.EditorFor(model => model.Description, new { htmlAttributes = new { @readonly = "readonly" } })
works for me
<%= Html.TextBox("Email", "abc@example.com", new { @class = "required email", @readonly="readonly" } )%>
@ symbol bypasses the reserved word.
<%= Html.TextBox("Email", "abc@example.com", new { @class = "required email", readonly="true" } )%>
精彩评论