I use this code in ASP.NET 4 for creating menu and add StaticSelectedStyle & DynamicSelectedStyle for highlight menu item for current page :
<asp:Menu ID="Menu1" runat="server" BackColor="#E3EAEB"
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#666666" Orientation="Horizontal" RenderingMode="List"
StaticSubMenuIndent="10px">
<DynamicSelectedStyle backcolor="LightBlue"
borderstyle="Solid"
bordercolor="Black"
borderwidth="1"/>
<StaticSelectedStyle backcolor="LightBlue"
borderstyle="Solid"
bordercolor="Black"
borderwidth="1"/>
</asp:Menu>
But for dynamic pages highlight current item is not working.
What is wrong?
Is there better way for highlight menu item for current page?
You need to set the Selected MenuItem Manually
I've created a function to make highlighting easier.
It takes the Value of the MenuItem and the Menu control instance as Parameters.
code-behind:
Limitations:
There is no way to select 2 or more MenuItem at once, so the parentMenu cannot be higlighted also if one of its submenu is selected. well you can do this in jQuery though.
If you have 2 or more menuItems that has the same Value, the first one will be selected.