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

  • Home
  • SEARCH
  • 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 4117414
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:49:56+00:00 2026-05-20T22:49:56+00:00

I have a Visual Studio 2010 and when I added a NEW project, VS

  • 0

I have a Visual Studio 2010 and when I added a NEW project, VS gives me default css and UI themes. I have 6 aspx pages. Now whenever user is going into some specific page, I want the menu bar of that page to get highlighted so that user will know which page he/she is.

I have a page called: CommSetup.aspx. In the page_load I have written this code:

And in the master page I changed this:

In code behind:

protected void Page_Load(object sender, EventArgs e)
    {
        foreach (MenuItem item in NavigationMenu.Items)
        {
            var navigateUrlParams = item.NavigateUrl.Split('/');
            if (Request.Url.AbsoluteUri.IndexOf(navigateUrlParams[navigateUrlParams.Length - 1]) != -1)
            {
                item.Selected = true;
            }
        }
    }

Markup:

 <body runat ="server" clientidmode ="Static" id = "MasterBody">
    <form runat="server">......
<asp:Menu ID="NavigationMenu" runat="server"  StaticSelectedStyle-CssClass ="Selected"      CssClass="menu" .....

This is what I added in Site.css:

div.menu ul li a.Selected
{
    background-color: #bfcbd6;
    color: #465c71;
    text-decoration: none;
}
  • 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-20T22:49:57+00:00Added an answer on May 20, 2026 at 10:49 pm

    Here’s an example of doing exactly what you’re asking for using CSS:

    http://hicksdesign.co.uk/journal/highlighting-current-page-with-css

    You should be able to achieve that using static ID naming on your controls (instead of letting ASP.NET assign the ID value to each control).

    EDIT:
    To get this to work with a master page, change the <body> tag in your master page to:

    <body runat="server" clientidmode="Static" id="MasterBody">
    

    Then in the Page_Load of each page, you can overwrite the id for each page (the master page in my example is of type SiteMaster):

    protected void Page_Load(object sender, EventArgs e)
    {
        Control c = Page.Master.FindControl("MasterBody");
        if (c != null)
        {
            c.ID = "Page1";
        }
    }
    

    Update (2):

    I tried running Farzin’s example and it didn’t seem to work, so here is what I was able to verify worked for me (you won’t need the Page_Load from before in your content pages):

    Site.master

    <asp:Menu ID="NavigationMenu" ...>
        <StaticSelectedStyle CssClass="selected" />
        ...
    </asp:Menu>
    

    Site.master.cs

    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (MenuItem item in NavigationMenu.Items)
        {
            item.Selected = Page.ResolveUrl(item.NavigateUrl).ToLowerInvariant() == Request.Path.ToLowerInvariant();
        }
    }
    

    Styles/Site.css

    div.menu ul li a.selected
    {
        /* put your style definition here */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a new project written in Visual Studio 2010, and I have checked
In Visual Studio 2010 ultimate I have added a local database to my project.
I have installed Visual Studio 2010 (final) and then Visual Studio 2008. Now I
I have a Visual Studio 2010 C# project which creates an .exe and this
I have added the following code in my C#.net application in visual studio 2010
I am developing an MVC3 application using Visual Studio 2010. I have an aspx
I have created a website in Visual Studio 2010 (File -> New Web Site),
I start Microsoft Visual Studio 2010. I chose to start a new project on
I am fairly new to development, and Visual Studio 2010. I have a solution
I have a console application written using Visual Studio 2010 / C#. I added

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.