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?
Short of overriding RenderContents on Menu, your options are very limited. Most of what you’d need is private and sealed and you won’t get anywhere there.
My solution would be to use templates. You could use MenuItem.Value or Depth and and ItemIndex to identify each item and provide necessary attributes.
In Page:
In Code (never mind silliness of this code, it is just to demonstrate the principle):