Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I'm new to posting on this site, but have found it quite useful for finding information. I have a problem however, and am not able to find a solution anywhere. i have a masterpage with a navigation menu. The menu items open different pages, and i am able to highlight the selected menu item by using the "StaticSelectedStyle" property, and style sheet.

The problem i have now, is that I have a second page, which is not directly called from the menu, but when this page opens, I want a certain menu to be highlighted.

Example:

Page1 gets called directly by MenuItem1 - When Page1 displays, MenuItem1 is highlighted.

From Page1, I have a button that calls Page2 (this page is not called in any menu). Now, MenuItem1 is not highlighted anymore, but I still want it to be highlighted.

Is this possible at all?

Thanx in advance!
Posted

1 solution

I think i solved my own problem. Without sessions and the lot. Was quite easy in the end, but thanx for your reply.

In MasterPage Load, loop through menu items and do some checks. Since the page being loaded accesses the masterpage, you just need to set the specific menuitems selected value to true. So, even though my item "AAA" has a different URL link, the menu item will be highlighted if it's own page is loaded, as well as when page "BBB" is loaded.
In SiteMaster Page_Load:
C#
foreach(MenuItem item in NavigationMenu.Items)
{
if (item.Value == "AAA" && Request.Path == "/BBB.aspx")
{item.Selected =true;}
else
{
item.Selected = Page.ResolveUrl(item.NavigateUrl).ToLowerInvariant() == Request.Path.ToLowerInvariant();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900