1

I want to get current action name in master page, so that i can find the "current" page link and mark it as "current".

Here is my view code snippet from Master Page:

<ul>
  <li>
    <a href="<%= Url.Action("Index", "Admin")%>" class="main current">Index</a>
  </li>
  <li>
    <a href="<%= Url.Action("Show", "Admin")%>" class="main">Show</a>
  </li>
  <li>
    <a href="<%= Url.Action("Delete", "Admin")%>" class="main">Delete</a>
  </li>
</ul>

As you can see, the Index hyperlink has a class of "current", which makes it highlighted via css files.

I want to check the Action that user is visiting, and make the hyperlink "current" with respect to that. I have searched through web, and wondering what is the best solution to that?

Also, I appreciate if you guys have any other suggestions about accomplishing this task.

Thanks in advance, Sadullah

PS: Even though I found the solution, there must be a nicer way to do this.

SadullahCeran
  • 2,425
  • 4
  • 20
  • 34
  • possible duplicate of [ASP.NET MVC - Current Action](http://stackoverflow.com/questions/362514/asp-net-mvc-current-action) – Kirk Woll Feb 25 '11 at 23:04

0 Answers0