Highlighting the current menu item From Collection of menu In Asp.Net 2.0 Menu Control

Highlighting the current menu item From Collection of menu Items In Asp.net 2.0 Menu control

In Asp.Net 2.0 Menu There Are Often Required to Highlight Current Selected Menu Item. There are various Way to Do it.One Method For Doing This One Describe Below.
string ThisPage = Page.AppRelativeVirtualPath;
foreach (MenuItem ParentMenu in Menu2.Items)
{
if (ParentMenu.NavigateUrl == ThisPage)
{
ParentMenu.Selected = true;
}
else
{
foreach (MenuItem childMenu in ParentMenu.ChildItems)
{
if (childMenu.NavigateUrl == ThisPage)
{
childMenu.Selected = true;
}
}
}
}

Prev Post                                                      All Post                                                           Next Post

Posted in |

1 comments:

  1. Anonymous Says:

    This would be handy in VB.net if someone could translate

Post a Comment