Lower Level Menu Items CSS

Apr 4, 2011 at 6:09 PM

The current CSS that came with this controls the entire menu list look and feel as a whole.  Does anyone have any sample CSS of how they have controlled lower levels of the menus independantly through CSS?  Thanks so much, this is fabulous!

May 10, 2011 at 7:05 PM
Edited May 10, 2011 at 7:05 PM

This took me a while to figure out, the CSS can be modified for submenu using System.Web.UI.WebControls.MenuItemStyle, I may have made some errors but this sample should help you get going (i used in the CreateChildControls()), functions are string, initially coded with defaults for sharepoint wss 3.0:

ms-navSubMenu1
ms-navSubMenu2

etc.. etc.. but you can use your custom class

 

MenuItemStyle _itemStyle1 = new MenuItemStyle();
_itemStyle1.CssClass = Set_Level1ItemStyles;  // level 1 Menu Items
if (Set_Level1ItemForeColor != "") { _itemStyle1.ForeColor = Color.FromName(Set_Level1ItemForeColor); }
if (Set_Level1ItemBackColor != "") { _itemStyle1.BackColor = Color.FromName(Set_Level1ItemBackColor); }
_spMenu.LevelMenuItemStyles.Add(_itemStyle1);
MenuItemStyle _itemStyle2 = new MenuItemStyle();
_itemStyle2.CssClass = Set_Level2ItemStyles; // level 2 Menu Items
_spMenu.LevelMenuItemStyles.Add(_itemStyle2);

SubMenuStyle _subStyle1 = new SubMenuStyle();
_subStyle1.CssClass = Set_Level1SubItemStyles; // level 1 Subenu Items
_spMenu.LevelSubMenuStyles.Add(_subStyle1);
SubMenuStyle _subStyle2 = new SubMenuStyle();
_subStyle2.CssClass = Set_Level2SubItemStyles; // level 2 Menu Items
_spMenu.LevelSubMenuStyles.Add(_subStyle2);

MenuItemStyle _selectedStyle1 = new MenuItemStyle();
_selectedStyle1.CssClass = Set_Level1SelItemStyles;
_spMenu.LevelSelectedStyles.Add(_selectedStyle1); // level 1 selected 
MenuItemStyle _selectedStyle2 = new MenuItemStyle();
_selectedStyle2.CssClass = Set_Level2SelItemStyles;
_spMenu.LevelSelectedStyles.Add(_selectedStyle2); // level 2 selected