Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Feature: MVC Support Adding HTML Attributes to SelectListItems [9]

$
0
0
I would like the ability to add Html attributes to individual SelectListItems via object htmlAttributes. This would be handy for applying CSS to selected options on render. I have working code for this (using the MVC3 source as the base) that I have used on client websites so it will be easy to integrate.
Comments: I'm not sure if there's much more to add, @HongmeiG. I would envision a new property (of type System.Object) on SelectListItem (maybe called "Attributes" or "HtmlAttributes"), assigned using a syntax similar to the one I posted in my comment (a Func<Object, Object> parameter to the SelectList ctor). Then any call to @Html.DropDown and its ilk would honour that property and generate data- attributes for each <option> element. Does that make sense?

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>