Question

I need to set the background for the currently active menu item?

I have used these

 <StaticSelectedStyle CssClass="selectedMenuItem" />

CSS:

 .DivLeftContent .selectedMenuItem:visited
  {
      background-color:#FBB2F7 ! important;
  } 

It is not worked.. Then i used this.

CSS:

.MenuItem a.static.selected
{
background-color:Black ! important;
}

OnPageLosd of master page

   string path = Request.AppRelativeCurrentExecutionFilePath;
   foreach (MenuItem item in menuItem.Items)
   {
     item.Selected = item.NavigateUrl.Equals(path,StringComparison.InvariantCultureIgnoreCase);
   }

This is also not working..

I am using ASP.NET 3.5 and creating menu in master page.

Help me..

Thanks..

Was it helpful?

Solution

There is a tricky way to do that..when you select a menu item on the code behind of the master page, check for the local URL path and change the background of the selected menu item based on Local URL which is Unique. and call that method in div class property using Eval Expression so that it will change the background of the selected menu item dynamically..

Let me know if you need more detail..

OTHER TIPS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top