pauldunlop
pauldunlop

Reputation: 474

ASP.NET MVC CSS classes on HTML.Controls

I think I'm missing something relatively simple here, but I'm trying to find a way of applying a CSS class to my controls within my views. I'm using the

<%= Html.SubmitButton("Submit", "Edit Plot")%>

style method of doing this. Short of putting divs around these elements and applying the styling, is there anyone way of getting access to the CssClass property that would be available in normal .NET?

Upvotes: 4

Views: 3617

Answers (1)

veggerby
veggerby

Reputation: 9020

Check out http://blog.veggerby.dk/2008/11/19/aspnet-mvc-htmlhelper-methods-and-css-class/, it is simply:

<% = Html.TextBox("name", null, new{ @class = "required"})  %>

Upvotes: 9

Related Questions