Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 405
pauldunlop Avatar asked Jan 24 '23 20:01

pauldunlop


1 Answers

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"})  %>
like image 120
veggerby Avatar answered Jan 27 '23 06:01

veggerby