Lets Have a fun with Technology.

BTemplates.com

Follow by Email

Monday, September 8, 2008

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

1 comment:

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

    ReplyDelete