Have you seen this post?http://forums.asp.net/t/1262938.aspx
I had the exact same problem (at least I think I did), and for me, it was that I was expecting the adapter to do the compare between the current page and the navigationURL property of the menu node and add the "Asp-Net-Menu" class to it. Turns out, we have
to do that manually, ourselves.
kiekar01
Member
58 Points
95 Posts
Unable to get .AspNet-Menu-Selected to work
May 20, 2008 08:56 PM|LINK
Hello,
What I'm trying to accomplish is to have a horizontal selected menu item background color different form the rest of the menu items for
the page whick is presently loaded.
I've been playing around with the .AspNet-Menu-Selected class with no success.
Any help would be much appreciated.
Below is the markup and css I used.
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <link href="CSS/Import.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" runat="server"> <div id="wrapper"> <div id="header"> <asp:Menu ID="MainMenu" runat="server" SkinID="MainMenu" CssSelectorClass="MyMenu"> <Items> <asp:MenuItem Text="Home" NavigateUrl="~/Default.aspx"/> <asp:MenuItem Text="Services" NavigateUrl="~/Services.aspx" /> <asp:MenuItem Text="Contact us" NavigateUrl="~/ContactUs.aspx" /> </Items> </asp:Menu> </div> <div id="contentarea"> <div id="maincontent">Main content goes here... <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> <div id="rightbar">Right side....</div> </div> </div> <div id="footer"> Footer goes here... </div> </form> </body> </html>HeaderMenu.css
masterpage.css
* {margin: 0; padding: 0;} html, body, form { font-family: Trebuchet MS, Arial, Verdana, Sans-Serif; font-size: 100%; height: 100%; } #wrapper { width: 50em; margin: auto; border: solid 1px #e3e3e3; min-height: 100%; margin-top: -2em; } * html #wrapper {height: 100%;} /* ie5-6 */ #header { position: relative; height: 8em; border: solid 1px #e6e6e6; border-top: solid 2em #fff; } #maincontent { float: left; width: 69%; border: solid 1px #e3e3e3; } #rightbar { float: right; width: 30%; border: solid 1px #e3e3e3; } #footer { width: 50em; height: 2em; margin: auto; background: #e3e3e3; }MainMenu.skin
DonBrown199
Member
15 Points
16 Posts
Re: Unable to get .AspNet-Menu-Selected to work
Jun 19, 2008 09:24 PM|LINK
Have you seen this post?http://forums.asp.net/t/1262938.aspx
I had the exact same problem (at least I think I did), and for me, it was that I was expecting the adapter to do the compare between the current page and the navigationURL property of the menu node and add the "Asp-Net-Menu" class to it. Turns out, we have to do that manually, ourselves.
The post above explains how to do that.
Hope this helps.
Don