Quantcast
Channel: ASP.NET MVC / Web API / Web Pages
Viewing all articles
Browse latest Browse all 7925

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: This is a great idea, but it can be even better with another overload that instead of just adding data attributes for every SelectListItem, consider adding a function as the parameter that can generate whatever parameter you want to based on the return value of the function. That way you can put together a nice lambda expression that returns a data attribute depending on the value or text of the SelectListItem.

Viewing all articles
Browse latest Browse all 7925

Trending Articles



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