我有一个菜单,旁边显示子菜单。
foreach (Category menuItem in lstMenu)
{
if (menuItem.ParentID == 0) //if its a main menu element
{
if (menuItem.CategoryID == requestedid)//if its the requested menu, highlight it
{
objStringBuilder.Append("<li class='active'><a href='Listing?id=" + menuItem.CategoryID + "&name=" + menuItem.CategoryDescription + "'>" + menuItem.CategoryDescription + "</a></li>");
}
else// if not, then dont
{
objStringBuilder.Append("<li><a href='Listing?id=" + menuItem.CategoryID + "&name=" + menuItem.CategoryDescription + "'>" + menuItem.CategoryDescription + "</a></li>");
}
}
else //if its a submenu element
{
if (menuItem.CategoryID == requestedid)//if its the requested submenu, highlight it
{
objStringBuilder.Append("<ul class='nav navbar-nav2'><li class='active'><a href='Listing?id=" + menuItem.CategoryID + "&name=" + menuItem.CategoryDescription + "'>" + menuItem.CategoryDescription + "</a></li></ul>");
}
else// if not, then dont
{
objStringBuilder.Append("<ul class='nav navbar-nav2'><li><a href='Listing?id=" + menuItem.CategoryID + "&name=" + menuItem.CategoryDescription + "'>" + menuItem.CategoryDescription + "</a></li></ul>");
}
}
}
我需要的是,当子菜单突出显示时,主菜单元素不应该是。当然它会突出显示子菜单(当请求子菜单时)以及主菜单元素(子菜单的父级)。我该怎么办?