I would like to pass the html input class attribute in ASP.NET MVC for my input box using Html.TextBox("FullName", null, new{class="grey-input"}). But I think I can use the "class" keyword.
How can I bypass this issue?
I would like to pass the html input class attribute in ASP.NET MVC for my input box using Html.TextBox("FullName", null, new{class="grey-input"}). But I think I can use the "class" keyword.
How can I bypass this issue?
yeh you need to use @class which allows you to use a reserved word.
Html.TextBox("FullName", null, new{@class="grey-input"})
So an example:
<%= Html.TextBox("Name","Andy",new{@class="Test"}) %>
Produces
<input class="Test" id="Name" name="Name" type="text" value="Andy" />
You could also create a custom Extension method for this also, but the above way is what I use.