3

This is probably easy, although I cant seem to find the solution. In my view I have links in a partial view which acts as a menu. I need to apply an active class to the anchors if they are the page currently being viewed.

What I therefore need is a quick and simple method of checking the href of the link against the url of the page?

Any takers? :)

1 Answer 1

3
RouteData.GetRequiredString("action")

will give you the action that was used to render this view. As far as good practices are concerned I would recommend you writing an HTML helper that will do the job instead of polluting your views with C#.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.