• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

AP.net Menu on Masterpage looses hi-lite when linked to new page.

Hi, how do I "keep" which menu item is selected.

My menu is on the masterpage, and whenever i navigate to a content page, the menu items "selected backcolor" (you know what I mean) does not get applied.

I reckon its because the masterpage does not know where it is, cause its still only on itself... how do I have the content page tell the masterpage where we are now?
0
FadeDude
Asked:
FadeDude
  • 3
  • 2
1 Solution
 
BuginatorCommented:
Have you tried to enable Viewstate for the dropdown menu?
0
 
FadeDudeAuthor Commented:
hmm, no, but i am not neccecarily using dropdown menus...

When there is just one page, lets say default.aspx, the menu on the masterpage works as desired.. when clicking on a menu option, a postback occurs and that menu option show a diffrent back color.... showing that it is the current selection.

When i start linking to other pages (adding pages to the project, and it redirects to a page outsite of where it was loaded, i loose the "selected" look.
0
 
BuginatorCommented:
I see. On the postback event that occurs after clicking on a menu item, create a session that contains some info about the selected menu item, the ID for instance. Then in each page load event (when a page get's loaded) check if the session exists, and if so, get the ID. Then find the appropiate menu item by comparing the session ID and the menu ID's, and manually select the menu item that corresponds with the session ID.
0
 
FadeDudeAuthor Commented:
thanks, i was also thinking maybe using a url variable methog..?

Post to 2ndpage.aspx?page=2ndpage

and then catching that in the masterpage load event...

Will give it a try. Thanks
0
 
BuginatorCommented:
Yes of course, you could do that, but the url will then become slightly messy. You also have to remember everytime you create hyperlinks that you include the correct querystring value so that you highlight the correct menu item. If you ask me, this would be quite cumbersome. That's why I think sessions is the best alternative of those two, as you don't need to hardcode url's, but instead only use one simple function that you use all the time on all the different pages. This solution could very easily be a enormous time saver if you later on need to change the page structure since you only need to alter this single function that affect the whole site, instead of changing every hyperlink on every page. Good luck either way!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now