I'm hoping to use an ASP.NET Menu Control for navigation through my site. However, I've got a requirement that each MenuItem must be styled differently (different colors, both static, and onHover). Without creating a custom class that would inherit from MenuItem, is this possible?
Thoughts on a better solution?
If anyone else bumps into the same question...
A quick and dirty method that worked for me is to force HTML contents into the MenuItem Text
(with appropriate escaping). You can then style it any way you want in your CSS, or even set each menu item to use a different style:
<asp:MenuItem Text="<span class="menuitem_text">Text Here</span>" />
The HTML ends up inside the <a>
tag:
<li><a ...><span class="menuitem_text">Text Here</span></a></li>