Valentin V
Valentin V

Reputation: 25739

How can I set a css class in Html.TextBox helper?

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.

Upvotes: 13

Views: 13347

Answers (1)

Seb Nilsson
Seb Nilsson

Reputation: 26408

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

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

Upvotes: 23

Related Questions