I’m looking at the StackOverflow website and I’ve noticed that there is a Class="youarehere" attribute set to the buttons of active views. This results in the orange styling instead of the grey styling.
Can anybody tell me how they’re doing this? What’s the easiest way to dynamically set the class based on the URL?
Writing an html helper for those buttons could be one way of doing it. Assuming the standard routing is set:
here’s how the helper might look like:
and finally add to your view:
To further improve the helper you could add additional parameters that will contain the action and the controller this button will redirect to when clicked.