0

I need to highlight current link in menu, But structure of HTML is look like below:

<li class="active">
    <a href='@Url.Action("MainPage", "Ticket")'>
        <i class="fa  fa-fw fa-home"></i>
        HomePage
    </a>
</li>

I know there are many different solutions to do that (+, +):

public static MvcHtmlString MenuLink(
            this HtmlHelper helper,
            string text, string action, string controller)
        {
            var routeData = helper.ViewContext.RouteData.Values;
            var currentController = routeData["controller"];
            var currentAction = routeData["action"];

            if (String.Equals(action, currentAction as string,
                      StringComparison.OrdinalIgnoreCase)
                &&
               String.Equals(controller, currentController as string,
                       StringComparison.OrdinalIgnoreCase))
            {
                return helper.ActionLink(
                    text, action, controller, null,
                    new { @class = "active" }
                    );
            }
            return helper.ActionLink(text, action, controller);
        }

But my HTML structure is a little bit different.
How can I do that?
Any idea?

Community
  • 1
  • 1
Sirwan Afifi
  • 10,654
  • 14
  • 63
  • 110