Since the <body> tag is in the Master page I don't know how to set a unique ID on the <body> tag for each page.

Both the <li> and <a> tags are generated from the asp.MenuItem so I don't see how to apply either an ID or a Class attribute.

If necessary I could forgo using the asp:menu control and just use simple HTML, but I would prefer to use the asp:menu control if that is possible. Even if I do resort to simple HTML (i.e. <ul> <li> <a> etc) for that part of the puzzle, I would really like to continue using a Master page.

This seems like a VERY common way to configure a menu so I am assuming there must be some sort of solution.

Any help will be greatly appreciated!!!

Thanks,
Steve

April 15th, 2011, 06:51 AM

RedBully

Re: CSS for Current Page with asp:Menu Control

Here is some sample code that works and should give you an idea of how to acheive what you want.

We have an Aspx page with a menu called MainMenu. We set two styles on it for menu items and selected menu items.

On page load in the code behind we build our menu and store an Identifer for each page in the menu item values. We then compare those item values with the name of the page we are currently on to work out which menu item we want to look differently. We then set the selected property on that menu item.

In this example, I have stored the actual page names but I normally use an enumerator and a lookup to a list of page names to make it easier to decouple the naming of the actual pages with the code for setting the menu items.

April 17th, 2011, 02:40 PM

sford

Re: CSS for Current Page with asp:Menu Control

Thanks RedBully!!!

I will give it a try... I appreciate your response!!!!

October 21st, 2013, 12:18 PM

Zero2Cool

Re: CSS for Current Page with asp:Menu Control

Quote:

Originally Posted by sford

Thanks RedBully!!!

I will give it a try... I appreciate your response!!!!

Did this solution work for you?

October 23rd, 2013, 02:33 AM

GremlinSA

Re: CSS for Current Page with asp:Menu Control

This thread is over two(2) years old and the user has not been active for over a year... I doubt he will reply on whether it worked for him or not...

If you have a similar problem, try the proposed fix, and if it does not work as expected, start a new thread with your problem and question and someone will try help you....

thanks...

October 23rd, 2013, 08:48 AM

Zero2Cool

Re: CSS for Current Page with asp:Menu Control

I had tried the proposed solution, hence why I asked if it worked for them as it did not for me.