0

I have master page with menu bar and a few nested pages. What is best practice to highlight selected menu item? For example:

[ Profile ] [Forum] [Statistics]


Statistics

blblalbla

2
  • I have no idea what you're asking. Do you seriousely not know about using CSS styles? Commented May 26, 2011 at 13:57
  • Are you asking how to know which one to highlight, or how to use CSS to give the appearance of a highlighted menu item? Commented May 26, 2011 at 14:35

4 Answers 4

1

This is what I use:

    //select menu item with matching NavigateUrl property
    foreach (MenuItem ParentMenu in menu.Items)
    {
        if (ParentMenu.NavigateUrl.ToLower() == Page.AppRelativeVirtualPath.ToLower())
        {
            ParentMenu.Selected = true;
        }
        else
        {
            foreach (MenuItem childMenu in ParentMenu.ChildItems)
            {
                if (childMenu.NavigateUrl.ToLower() == Page.AppRelativeVirtualPath.ToLower())
                {
                    childMenu.Selected = true;
                }
            }
        }
    }
Sign up to request clarification or add additional context in comments.

Comments

0

The best way would be to put the menu in a control. You can then have properties such as SelectedMenu which render the style of the selected menu item.

You can read about user controls here:

http://msdn.microsoft.com/en-us/library/fb3w5b53.aspx

They can be a little tricky at first, but once you have got the hang of them they will be very useful to you.

Comments

0

you can highlight the menuitem based on the current url.

Comments

0

Use StaticSelectedStyle and DynamicSelectedStyle properties

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.