Recently my task need convert this website http://www.royalecoach.com.au/royale.asp (this is wrote by using classic asp) into asp.net MVC.
First I need to create a layout.cshtml for my the new version of this website.Then navigation need add a class named active to it when the action method has been called.
The first way is very simpley, you could wirte a logic to your view, here is one solution:
But the rule of MVC is the view must be simply as possible, I don’t like this nasty and yuck c# code sit in there. So there is a way just by write a CustomHtmlHelpers to improve it.
here is my class file:
Then in your layout page ,your could use it like:
That’s it. By the way, I am using asp mvc4. Hope that could help some one else.