Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp.net-mvc

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.

like image 430
Valentin V Avatar asked Jun 15 '09 10:06

Valentin V


1 Answers

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

<%=Html.TextBox("Region", Model.Region, new { @class="Autocomplete" }) %>
like image 189
Seb Nilsson Avatar answered Sep 29 '22 06:09

Seb Nilsson