Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 245137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:03:49+00:00 2026-05-11T21:03:49+00:00

I have the following menu in my masterpage: <ul id=menu class=lavaLampBottomStyle> <li> <%= Html.ActionLink(Employees,

  • 0

I have the following menu in my masterpage:

<ul id="menu" class="lavaLampBottomStyle">
    <li>
        <%= Html.ActionLink("Employees", "Index", "Employees")%></li>
    <li>
        <%= Html.ActionLink("Customer", "Details", "Account")%></li>
</ul>

I need a way to set the css class of the current active li to “current”.

My first guess it to do this with the assistance of javascript.

I would include something like this in the masterpage:

  $("#menu li a").each(){
    if($(this).attr("href") == '<%= *GET CURRENT PAGE* %>'){
       $(this).parent("li").addClass("current");
    }
  }

Is this a good approach?

If it is, how can I get the current URL part like in the href?

If it isn’t, what’s your suggestion? 🙂

FYI, the generated html I’m after:

<ul id="menu" class="lavaLampBottomStyle">
    <li>
        <a href="/KszEmployees/Index">Employees</a></li>
    <li>
        <a class="current" href="/">Customer</a></li>
</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:03:49+00:00Added an answer on May 11, 2026 at 9:03 pm

    That’s probably the least intensive way of doing it. If you can count on the users to have javascript enabled, I see nothing wrong with this, and have done it myself on occasion.

    Request.Url is the object you are interested in to get the current page on the server side. The suggestion to use window.location.href by tvanfosson isn’t bad either if you want to keep it entirely clientside.

    The advantage of using serverside, is that Request.Url has easily accessible parts of the url, such as Request.Url.Host, etc to help with your link-munging needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following HTML menu: <ul> <li><a href=index.html>Index Page</a></li> <li><a href=#some-page>Some Page</a></li> </ul> Let
I have the following HTML code based on a tab menu format, i.e: <div
i have the following menu: <ul class=menu menu-vert-01> <!--start--> <li><a href=#Semantic-Technologies>Semantic Technologies</a></li> <li><a href=#Business-Intelligence-Solutions>Business
I have the following menu items generated by a template generator, artisteer: <ul class=art-vmenu>
I have the following menu. <ul id=nav class=grid_16> <li><a href=#>FORSIDE</a></li> <li><a href=#>MOBIL</a></li> <li><a href=#>PC
I have the following menu : <div> <ul class=menu> <li id=2 class=inactive><a href=frm_Items.aspx id=lnk_Draft
I have the following menu: <ul class=menu> <li class=menu_item><a href=mylink.php><img src=menu/home.png class=menu_img/></a></li> <li class=menu_item><a
I have the following menu items: <ul> <li class=static> <a class=static menu-item href=/mySites/AboutUs>About Us</a>
Considering the case, that I have the following menu: <ul> <li><a href=index.php>Index</a></li> <li><a href=about.php>About</a></li>
I have the following: class Menu < ActiveRecord::Base has_many :menu_headers # has_many :menu_headers, :conditions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.