I am trying to apply css on my html.dropdownlist with a regular html select list css. Can anyone show me how to go about doing this & where am I going wrong with this
this is what i have right now..
<div id='container'> Months <%=Html.DropDownList('dllMonths', new SelectList(new List<string>() { 'January', 'Feburary', 'March', 'April', 'June', 'July', 'August', 'September', 'October', 'November', 'December'}, ViewData['Month']), new { onchange = 'this.form.submit();' })%> Events <%=Html.DropDownList('dllEvents', new SelectList(new List<string>() { 'Camp Events', 'Weekly Events', 'All Events'}, ViewData['Event']), new { onchange = 'this.form.submit();' })%> </div>
and this is the css that i am trying to apply http://www.emblematiq.com/projects/niceforms/demo/
The part of your code where you use an anonymous object to set html properties, change it to this:
The @ symbol allows you to use a property name that is a reserved word. You can also add style=” if you want inline styling (but you probably don’t).
Also, you don’t need to new up SelectList, there’s an overload on Html.DropDownList() that lets you pass those same values.