开发者

Read only Textbox in ASP.net MVC View

开发者 https://www.devze.com 2022-12-18 07:13 出处:网络
How to set the re开发者_运维知识库adonly attribute to HTML Textbox helper class. <%= Html.TextBox("Email", "abc@example.com", new { @class = "required email" } )%>

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

精彩评论

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