2010-01-29 167 views

回答

65
<%= Html.TextBox("Email", "[email protected]", new { @class = "required email", @readonly="readonly" }) %> 
+0

這個解決方案應該用於跨瀏覽器嗎? – 2014-05-27 12:48:07

2
<%= Html.TextBox("Email", "[email protected]", new { @class = "required email", readonly="true" })%> 
+2

仙,球,只讀是保留字。我失敗了。 – Will 2010-01-29 21:00:22

+3

@符號繞過保留字。 – VoodooChild 2010-11-26 22:36:15

6
<%= Html.TextBox("Email", "[email protected]", new { @class = "required email", @readonly = "readonly" })%> 
2
<%= Html.TextBox("Email", "[email protected]", new { @class = "required email", @readonly="readonly" })%> 

@符號繞過保留字。

3

爲了獲得更好的性能,使用以下命令:

ASPX:

<%= Html.TextBox("Email", ew Dictionary<string, object> { {"class","required email"}, {"readonly","readonly"} } %> 

剃刀:

@Html.TextBoxFor(model => model.Email, new Dictionary<string, object> { { "class", "required email" }, {"readonly","readonly"} }) 
1
@Html.EditorFor(model => model.Description, new { htmlAttributes = new { @readonly = "readonly" } }) 

作品對我來說