Solved

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

Posted on 2009-04-10
5
282 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
  • 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 125 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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