call today Call Today 320.281.0605

Add css class attribute to html helpers in asp.NET MVC 2

August 26, 2010    Author: Joel

It took me forever to find out how to do this so hoping this will save someone else the time.

Here is an example:

<%= Html.TextBoxFor(model => model.Email, new { @class = "txtLarge" })%>

In asp.NET MVC I used _class it seems in MVC 2 you need to use the @ symbol.

Share
  • http://www.christianlouboutintobuy.com christian louboutin

    I am looking forward for your next post, I will try to get the hang of it

  • Guest

    What if you need to add two css classes rather than one?
    model.Email, new { @class = “txtLarge someOtherClass” })%> <– doesn't work…

  • http://www.astwoodconsulting.co.uk/ ms excel training

    There
    are many advantages to adopting the ASP system approach. The primary one
    being the cost savings it affords by spreading that cost among many
    customers. 

Agent Cody Banks 2 Destination London full lenght movie download Afghan Knights download movie Inside the Smiths download movie Beverly Hills Chihuahua download movie Permanent Vacation download movie Indiana Jones and the Kingdom of the Crystal Skull download movie Afghan Knights download movie Inside the Smiths download movie Beverly Hills Chihuahua download movie Permanent Vacation download movie Indiana Jones and the Kingdom of the Crystal Skull download movie