?
Solved

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

Posted on 2009-04-10
5
Medium Priority
?
311 Views
Last Modified: 2013-11-05
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
Comment
Question by:FadeDude
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:Buginator
ID: 24114547
Have you tried to enable Viewstate for the dropdown menu?
0
 

Author Comment

by:FadeDude
ID: 24114694
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
 
LVL 5

Accepted Solution

by:
Buginator earned 500 total points
ID: 24114720
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
 

Author Comment

by:FadeDude
ID: 24114773
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
 
LVL 5

Expert Comment

by:Buginator
ID: 24114824
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question