title: ASP.NET MVC: Masterpage: How to set css class on active menu item
body: <p>I have the following menu in my masterpage:</p>
  
  <pre><code>&lt;ul id="menu" class="lavaLampBottomStyle"&gt;
      &lt;li&gt;
          &lt;%= Html.ActionLink("Employees", "Index", "Employees")%&gt;&lt;/li&gt;
      &lt;li&gt;
          &lt;%= Html.ActionLink("Customer", "Details", "Account")%&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p><strong>I need a way to set the css class of the current active li to "current".</strong></p>
  
  <p>My first guess it to do this with the assistance of javascript.</p>
  
  <p>I would include something like this in the masterpage:</p>
  
  <pre><code>  $("#menu li a").each(){
      if($(this).attr("href") == '&lt;%= *GET CURRENT PAGE* %&gt;'){
         $(this).parent("li").addClass("current");
      }
    }
  </code></pre>
  
  <p><strong>Is this a good approach?</strong> </p>
  
  <p>If it is, how can I get the current URL part like in the href?</p>
  
  <p>If it isn't, what's your suggestion? :-)</p>
  
  <p>FYI, the generated html I'm after:</p>
  
  <pre><code>&lt;ul id="menu" class="lavaLampBottomStyle"&gt;
      &lt;li&gt;
          &lt;a href="/KszEmployees/Index"&gt;Employees&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;
          &lt;a class="current" href="/"&gt;Customer&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>