c# - Highlighting Menu Bar in ASP.NET Web Application -
i built web application using asp.net visual studio 2010 master pages. see project gives default menu bar item. have 5 pages (links) listed on menu bars. when user goes specific page want highlight menu bar link. dont know how :(
i tried on master page code behind didnt work too:
foreach (menuitem item in navigationmenu.items) { var navigateurlparams = item.navigateurl.split('/'); if (request.url.absoluteuri.indexof(navigateurlparams[navigateurlparams.length - 1]) != -1) { item.selected = true; } }
and in mark view have this:
<div class="clear hideskiplink"> <asp:menu id="navigationmenu" runat="server" cssclass="menu" enableviewstate="false" includestyleblock="false" orientation="horizontal" onmenuitemclick="navigationmenu_menuitemclick"> <items> <asp:menuitem text="test1"/> <asp:menuitem text="test2"/> <asp:menuitem text="test3"/> </items> </asp:menu> </div>
so whenever user comes test1.aspx page, want menu item of test1 highlighted. how should that?
any appreciated! thank you...
use css link classes implement this:
http://www.w3schools.com/css/sel_active.asp
and unless "need" programmatic against these link items, use html anchor links instead. create them list items:
<ul class="menu"> <li> <a href="~/home" id="link1" title="first link" runat="server">link 1</a> </li> </ul>
what i'm saying question if controls necessary here (not familiar project), , keep markup simple whenever possible.
Comments
Post a Comment