Saturday 15 September 2012

asp.net - Asp.menu - staying hover effect when active -



asp.net - Asp.menu - staying hover effect when active -

i have masterpage asp.net menu command is.

what want that, if click link in menu, want menu item clicked remain hover effect aslong active.

is there chance possible asp.net menu ? :)

i have tried code found online:

<div class="topnav"> <asp:menu id="topnav" runat="server" orientation="horizontal" renderingmode="list" skiplinktext="" maximumdynamicdisplaylevels="1" viewstatemode="enabled" > <items> <asp:menuitem navigateurl="~/default.aspx" text="home" value="home"></asp:menuitem> <asp:menuitem navigateurl="~/overview.aspx" text="overview" value="overview"></asp:menuitem> <asp:menuitem navigateurl="~/benefits.aspx" text="benefits" value="benefits"></asp:menuitem> <asp:menuitem navigateurl="~/home.aspx" text="hardware" value="hardware"></asp:menuitem> <asp:menuitem navigateurl="~/sdk.aspx" text="develop" value="sdk"></asp:menuitem> </items> </asp:menu> </div> .topnav { background-color: #ddd; /*margin-top: 1px;*/ line-height: 22px; float: right; margin-right: 11px; background: url(../img/shadow.gif) repeat-y top right; font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #777; text-align: center; } .topnav #topnav li { float: left; } .right .topnavcont { width: 767px; background-color: #dddddd !important; height: 22px; } .topnav li { width: 109px; } .topnav a:link, .topnav a:visited { color: #777; display: block; background-image: url(../img/bg_n-s.gif); background-repeat: repeat-x; text-decoration: none; visibility: visible; } .topnav a:hover { color: #fff !important; background-image: url(../img/bg_h-s.gif); display: block; visibility: visible; } topnav .staticmenuitemselected { color: red; display: block; background-image: url(../img/bg_n-s.gif); background-repeat: repeat-x; text-decoration: none; visibility: visible; }

loop through menuitem , check if current page url contains navigateurl

foreach (menuitem item in mn.items) { if (request.url.absoluteuri.tolower().contains(page.resolveurl(item.navigateurl.tolower())) { item.selected = true; } } refer [http://stackoverflow.com/questions/8053337/asp-net-4-highlight-menu-item-for-current-page]

_______ or ___________

there's staticselectedstyle property within menu.

<asp:menu id="menu" runat="server" > <staticselectedstyle backcolor="" borderstyle="" bordercolor="" borderwidth=""/> </menu> find more [http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.includestyleblock.aspx] , [http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.staticselectedstyle.aspx]

asp.net menu hover master-pages

No comments:

Post a Comment