System.Web.UI.WebControls Namespace Menu Class
.NET Framework version 2.0
Returns a collection of MenuItem objects that represents the root menu items in a Menu control.
Script |
[ MenuItemCollection variable = ] Menu.Items |
The property is read/write with no default value.
Use the Items collection to programmatically obtain information about each root menu item in a Menu control. This collection is typically used to iterate through all the root menu items, or to access a specific root menu item.
The Items property can also be used to programmatically add, insert, or remove MenuItem objects in the collection. Any updates to the collection are automatically reflected in the Menu control after the next round trip to the server.
To access the child menu items of a root or parent menu item, use the ChildItems property of the menu item ( or the subsequent parent-level menu item ) to navigate down the menu hierarchy.
The following example shows how to programmatically add MenuItem objects to the Items collection of a Menu control.
MenuItem newItem = new MenuItem ( menuItemText, menuItemValue );
newItem.NavigateUrl = webPageUrl;
menuObject.Items.Add ( newItem );
Show me
Menu Members MenuItem