开发者

Read only Textbox in ASP.net MVC View

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" } )%>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜