I created a web application using ASP.NET Visual Studio 2010 with the main pages. As you will see, the project gives us the default menu item. I have 5 pages (links) listed in these menus. Now, when the user goes to a specific page, I want to highlight this link in the menu bar. I do not know how to do that: (
I tried this in the code of the main page, but it did not work either:
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 my markup view, I have the following:
<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>
Therefore, when the user comes to the Test1.aspx page, I want to highlight the menu item Test1. How should I do it?
Any help would be appreciated! Thank...
Rg-3 source
share