You need to use HtmlAttributes for this , but there is catch: HtmlAttributes and css class .
you can define it as follows:
new { Attrubute="Value", AttributeTwo = IntegerValue, @class="className" };
and here is a more realistic example:
new { style="width:50px" }; new { style="width:50px", maxsize = 50 }; new {size=30, @class="required"}
and finally in:
MVC 1
<%= Html.TextBox("test", new { style="width:50px" }) %>
MVC 2
<%= Html.TextBox("test", null, new { style="width:50px" }) %>
MVC 3
@Html.TextBox("test", null, new { style="width:50px" })
Nikita Ignatov Nov 28 '08 at 4:58 2008-11-28 04:58
source share