hi all I have a MenuItem that im dynamically adding childrent to using the following code
MenuItem c1 = new MenuItem("text","value");
parent.ChildItems.Add(c1);
however I need to add a css class to it at the the same time something like
c1.cssClass = "cssclass";
or
c1.attributes.Add("Class","cssclass");
does anyone know how?
MenuItemdoesn’t have a CSS class property, instead add the class to the parentMenu:If you want to dynamically add classes to the menu then try creating a helper method (Extension Methods in C#):
Since our
Menurenders aULyou can then use CSS selectors to cascade the style to all childLIelements:Or alternatively, specific
LIelements (things like nth-child etc are only supported in CSS 3.0):