tags:

views:

722

answers:

1

Is it possible to set a css class in a TextBox html helper? This doesn't compile, obviously:

<%=Html.TextBox("Region",Model.Region,new {class="Autocomplete"}) %>

Thanks.

+8  A: 

Class is a reserved keyword, so you need to write it like this:

<%=Html.TextBox("Region", Model.Region, new { @class="Autocomplete" }) %>
Seb Nilsson
This is great! I love the fact that google is indexing these pretty well now. I found this solution within 60 seconds of asking myself "how do I set the class attribute?"
Ogre Psalm33