Solved

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

Posted on 2009-04-10
5
265 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now