System.Web
2.0.0.0
System.Object
System.ICloneable
System.Web.UI.IStateManager
System.Web.UI.ParseChildren(true, "ChildItems")
A control is made up of a hierarchy of menu items represented by objects. Each menu item has a read-only property that specifies the level at which the menu item is displayed in the control. Menu items at the top level (level 0) that do not have a parent menu item are called root menu items. A menu item that has a parent menu item is called a submenu item. All root menu items are stored in the collection. Submenu items are stored in a parent menu item's collection. You can access a menu item's parent menu item by using the property.
The and collections contain only the menu items for the next level down. To access menu items further down the menu tree, use the property of a subsequent menu item.
To create the menu items for a control, use one of the following methods:
Use declarative syntax to create static menu items.
Use a constructor to dynamically create new instances of the class. These objects can then be added to the or collection.
Bind the control to a data source. When the control is bound to a control, objects are automatically created that correspond to the items in the data source. For other data sources, objects are also automatically created that match the hierarchy structure of data source; however, you must also use the collection to define the menu item bindings that specify the binding relationship between a menu item and its corresponding data item.
The menu items are displayed in either a static menu or a dynamic menu, depending on its level. The static menu is always displayed in a control. By default, the menu items at the top level (level 0) are displayed in the static menu. You can display additional menu levels (static submenus) within the static menu by setting the property. Menu items (if any) with a higher level than the value specified by the property are displayed in a dynamic submenu. A dynamic submenu appears only when the user positions the mouse pointer over the parent menu item that contains a dynamic submenu.
When the user clicks a menu item, the control can either navigate to a linked Web page or simply post back to the server. If the property of a menu item is set, the control navigates to the linked page; otherwise, it posts the page back to the server for processing. By default, a linked page is displayed in the same window or frame as the control. To display the linked content in a different window or frame, use the property of the control.
The property affects every menu item in the control. To specify a window or frame for an individual menu item, set the property of the object directly.
Each menu item has a and a property. The value of the property is displayed in the control, while the property is used to store any additional data about the menu item, such as data passed to the postback event associated with the menu item. If you set the property, but leave the property unset, the property is automatically set with the same value as the property. The opposite is also true. If you set the property, but not the property, the property is automatically set with the same value as the property.
Menu items at the same menu level must each have a unique value for the property; the control cannot distinguish between different menu items at the same level that have the same value. In this scenario, if the user clicks a menu item that has a duplicate value, the menu item that appears first in the menu is selected.
To display a ToolTip when the user positions the mouse pointer over a menu item, set the item's property.
A control has several different types of menu items. You can control the style (such as font size and color) for the different menu item types by using the properties in the following table.
-
Menu item style property
Description
-
The style settings for a dynamic menu item when the mouse pointer is positioned over it.
-
The style settings for an individual dynamic menu item.
-
The style settings for a dynamic menu.
-
The style settings for the currently selected dynamic menu item.
-
The style settings for a static menu item when the mouse pointer is positioned over it.
-
The style settings for an individual static menu item.
-
The style settings for a static menu.
-
The style settings for the currently selected static menu item.
Instead of setting the individual style properties, you can specify styles that are applied to menu items based on their level by using the style collections shown in the following table.
-
Level style collections
Description
-
A collection of objects that control the style of the menu items based on their level.
-
A collection of objects that control the style of selected menu items based on their level.
-
A collection of objects that control the style of the submenu items based on their level.
The first style in the collection corresponds to the style of the menu items at the first depth level in the menu tree. The second style in the collection corresponds to the style of the menu items at the second depth level in the menu tree, and so on. This is most often used to generate table of contents-style navigation menus where menu items at a certain depth should have the same appearance, regardless of whether they have submenus.
If you use any of the level style collections listed in the previous table to define the style for the control, these style settings override the individual menu item style properties.
In addition to customizing a menu item's style, you can also customize its appearance. You can specify custom images for the different parts for a menu item by setting the properties in the following table.
-
Image property
Description
-
An optional image displayed next to the text of a menu item.
-
An optional image displayed in a menu item to indicate that the menu item has a dynamic submenu.
-
An optional image displayed at the bottom of a menu item to separate it from other menu items.
To determine whether a menu item is currently selected in a control, use the property. You can also determine whether a menu item is bound to data by using the property. If a menu item is bound to data, you can use the property to access the values of the data item bound to the menu item.
For a list of initial property values for an instance of the class, see the constructor.
Represents a menu item displayed in the control. This class cannot be inherited.
Constructor
Use this constructor to create a new instance of a class without menu text or a value.
When this constructor is used, all properties in the object are set to their default values. Be sure to set the properties, as necessary, after creating the object.
This constructor is commonly used when dynamically populating the collection of a control or the collection of a object.
Initializes a new instance of the class without menu text or a value.
2.0.0.0
Constructor
Use this constructor to create a new instance of the class using the menu text specified by the parameter.
The following table shows the initial property value for an instance of the class.
-
Property
Initial value
-
The value of the text parameter.
This constructor is commonly used when dynamically populating the collection of a control or the collection of a object.
Initializes a new instance of the class using the specified menu text.
The text displayed for a menu item in a control.
2.0.0.0
Constructor
Use this constructor to create a new instance of the class using the menu text and value specified by the and parameters, respectively.
The following table shows initial property values for an instance of the class.
-
Property
Initial value
-
The value of the parameter.
-
The value of the parameter.
This constructor is commonly used when dynamically populating the collection of a control or the collection of a object.
Initializes a new instance of the class using the specified menu text and value.
The text displayed for a menu item in a control.
The supplemental data associated with the menu item, such as data used for handling postback events.
2.0.0.0
Constructor
Use this constructor to create a new instance of the class using the menu text, value, and image URL specified by the , , and parameters, respectively.
The following table shows initial property values for an instance of the class.
-
Property
Initial value
-
The value of the parameter.
-
The value of the parameter.
-
The value of the parameter.
This constructor is commonly used when dynamically populating the collection of a control or the collection of a object.
Initializes a new instance of the class using the specified menu text, value, and URL to an image.
The text displayed for a menu item in a control.
The supplemental data associated with the menu item, such as data used for handling postback events.
The URL to an image displayed next to the text in a menu item.
2.0.0.0
Constructor
Use this constructor to create a new instance of the class using the menu text, value, image URL, and navigation URL specified by the , , , and parameters, respectively.
The following table shows initial property values for an instance of the class.
-
Property
Initial value
-
The value of the parameter.
-
The value of the parameter.
-
The value of the parameter.
-
The value of the parameter.
This constructor is commonly used when dynamically populating the collection of a control or the collection of a object.
Initializes a new instance of the class using the specified menu text, value, image URL, and navigation URL.
The text displayed for a menu item in a control.
The supplemental data associated with the menu item, such as data used for handling postback events.
The URL to an image displayed next to the text in a menu item.
The URL to link to when the menu item is clicked.
2.0.0.0
Constructor
Use this constructor to create a new instance of the class using the menu text, value, image URL, navigation URL, and target specified by the , , , , and parameters, respectively.
The following table shows initial property values for an instance of the class.
-
Property
Initial value
-
The value of the parameter.
-
The value of the parameter.
-
The value of the parameter.
-
The value of the parameter.
-
The value of the parameter.
This constructor is commonly used when dynamically populating the collection of a control or the collection of a object.
Initializes a new instance of the class using the specified menu text, value, image URL, navigation URL, and target.
The text displayed for a menu item in a control.
The supplemental data associated with the menu item, such as data used for handling postback events.
The URL to an image displayed next to the text in a menu item.
The URL to link to when the menu item is clicked.
The target window or frame in which to display the Web page content linked to a menu item when the menu item is clicked.
2.0.0.0
Property
System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerDefaultProperty)
System.ComponentModel.Browsable(false)
System.ComponentModel.MergableProperty(false)
System.Web.UI.WebControls.MenuItemCollection
To be added.
Use the property (collection) to access the submenu items of the current menu item, if any. This collection contains only the menu items at the next level. To access menu items further down the menu tree, use the property of a subsequent menu item. If the property is null, the current menu does not have any submenu items.
The property can also be used to programmatically manage the submenu items of the current menu item. You can add, insert, remove, retrieve, and modify objects from the collection. Any updates to the collection will automatically be reflected in the control the next time the page is refreshed.
Gets a object that contains the submenu items of the current menu item.
2.0.0.0
Property
System.ComponentModel.Browsable(false)
System.ComponentModel.DefaultValue(false)
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
System.Boolean
To be added.
The property is used to programmatically determine whether the menu item was created through data binding.
Gets a value indicating whether the menu item was created through data binding.
2.0.0.0
Property
System.ComponentModel.Browsable(false)
System.ComponentModel.DefaultValue(null)
System.Object
To be added.
When the control is bound to a data source, such as an object, this property is set to the data item that is bound to this specific menu item. This property is commonly used to access the value of the data item.
This property is available only after data binding has occurred.
Gets the data item that is bound to the menu item.
2.0.0.0
Property
System.ComponentModel.Browsable(false)
System.ComponentModel.DefaultValue("")
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
System.String
To be added.
The property value is commonly used when calling the method to provide the path to the data that is bound to the current menu item. This method then returns a object that contains the data at the specified path.
Gets the path to the data that is bound to the menu item.
2.0.0.0
Property
System.ComponentModel.Browsable(false)
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
System.Int32
To be added.
Use the property to determine the depth of the menu item. The depth indicates the level at which a menu item is displayed and represents the number of levels of hierarchy between the current menu item and the root menu item. For example, a root menu item has a depth of 0. A submenu item of the root menu item has a depth of 1, and so on.
Gets the level at which a menu item is displayed.
2.0.0.0
Property
System.ComponentModel.DefaultValue(true)
System.ComponentModel.Browsable(true)
System.Boolean
To be added.
When this property is set to false, the menu item is disabled and no pop-out image indicating child items is displayed. Setting this property to false for a menu item essentially makes the menu item the end of that node, where no further levels are shown off of that node. The default value is true.
If you want the menu item to show any child items, but to not be "clickable" itself, use the property and set it to false.
Gets or sets a value that indicates whether the object is enabled, allowing the item to display a pop-out image and any child menu items.
2.0.0.0
Property
System.ComponentModel.Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))
System.Web.UI.UrlProperty
System.ComponentModel.DefaultValue("")
System.String
To be added.
Use the property to specify a custom image for the current menu item in the control. This image is displayed next to the menu item text and can be in any file format (.jpg, .gif, .bmp, and so on), as long as the client's browser supports that format.
Gets or sets the URL to an image that is displayed next to the text in a menu item.
2.0.0.0
Property
System.ComponentModel.Editor("System.Web.UI.Design.UrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))
System.Web.UI.UrlProperty
System.ComponentModel.DefaultValue("")
System.String
To be added.
A menu item can be in one of two modes: selection mode or navigation mode. By default, a menu item is in selection mode. To put a menu item into navigation mode, set the menu item's property to a value other than an empty string ("").
When a menu item is in navigation mode, all selection events are disabled for that menu item. Clicking the menu item in navigation mode takes the user to the specified URL. You can optionally set the property to specify the window or frame in which to display the linked content.
Gets or sets the URL to navigate to when the menu item is clicked.
2.0.0.0
Property
System.ComponentModel.Browsable(false)
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
System.Web.UI.WebControls.MenuItem
To be added.
Use the property to determine the parent menu item or to access its properties.
A root menu item does not have a parent menu item.
To access the submenu items of the current menu item, use the property.
Gets the parent menu item of the current menu item.
2.0.0.0
Property
System.ComponentModel.Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))
System.Web.UI.UrlProperty
System.ComponentModel.DefaultValue("")
System.String
To be added.
If is set to List, or if is set to Default and is set to 4.0 or later, this property has no effect. Use the property or the property instead of this property.
If is set to Table, or if is set to Default and is set to 3.5, use this property to specify a custom image that is displayed in a menu item to indicate that the menu item has a dynamic submenu. This image can be in any file format (.jpg, .gif, .bmp, and so on), as long as the client's browser supports that format.
Setting this property overrides the image specified by the and properties.
You can also disable this image in a static menu by setting this property to an empty string and setting the property to false. Similarly, you can disable this image in a dynamic menu by setting this property to an empty string and setting the property to false.
Gets or sets the URL to an image that is displayed in a menu item to indicate that the menu item has a dynamic submenu.
2.0.0.0
Property
System.ComponentModel.DefaultValue(true)
System.ComponentModel.Browsable(true)
System.Boolean
To be added.
When this property is set to false on a menu item, no action occurs when the menu item is clicked (selected). The pop-out image indicating child menu items for the menu item, if one exists, is still shown and available.
If you do not want any child menu items to appear for a menu item, set the property to false.
applies only to menu items that can be selected, in the sense that clicking a menu item posts back and sets that item in the selected state. Note that a menu item that cannot be selected is still formatted as a link. This is for accessibility reasons, so that the menu item can cause an action to occur. Also, a menu item, even if it cannot be selected, may have child menu items that can be selected or that need to be displayed.
If you want to prevent a user from clicking a menu item, do one of the following:
-
Do not set and set to false.
-
Set the menu item's property to false.
Gets or sets a value that indicates whether the object can be selected, or is "clickable."
2.0.0.0
Property
System.ComponentModel.Browsable(true)
System.ComponentModel.DefaultValue(false)
System.Boolean
To be added.
Use the property to specify or determine whether the current menu item is selected.
Although the property can be used to determine whether a menu item is selected, it is more common to use the property.
Only one menu item can be selected at a time in the control.
Gets or sets a value indicating whether the current menu item is selected in a control.
2.0.0.0
Property
System.ComponentModel.Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))
System.Web.UI.UrlProperty
System.ComponentModel.DefaultValue("")
System.String
To be added.
Use the property to specify a custom image (usually of a line) that is displayed at the bottom of a menu item to separate it from other menu items. This image can be in any file format (.jpg, .gif, .bmp, and so on), as long as the client's browser supports that format.
Gets or sets the URL to an image displayed at the bottom of a menu item to separate it from other menu items.
2.0.0.0
Method
2.0.0.0
System.Object
The method is used by the class to make a copy of itself.
Creates a copy of the current object.
An that represents a copy of the .
Property
2.0.0.0
System.Boolean
To be added.
Typically, you should use the member to determine whether a object is tracking view-state changes.
The member is an explicit interface member implementation. It can be used only when a instance is cast to an interface.
Gets a value that indicates whether the object is saving changes to its view state.
Method
2.0.0.0
System.Void
To be added.
To be added.
Loads the menu item's previously saved view state.
Method
2.0.0.0
System.Object
To be added.
Saves the view-state changes to an .
The that contains the view-state changes.
Method
2.0.0.0
System.Void
After this method has been called on a server control, the property returns true.
Instructs the object to track changes to its view state.
Property
System.ComponentModel.DefaultValue("")
System.String
To be added.
Use the property to specify the window or frame in which to display the Web content linked to a menu item when that menu item is clicked. Values must begin with a letter in the range of A through Z (case-insensitive), except for certain special values that begin with an underscore, as shown in the following table. Note that setting this property overrides the property of the control for this menu item.
-
Target value
Description
-
_blank
Renders the content in a new window without frames.
-
_parent
Renders the content in the immediate frameset parent.
-
_search
Renders the content in the search pane.
-
_self
Renders the content in the frame with focus.
-
_top
Renders the content in the full window without frames.
Check your browser documentation to determine if the _search value is supported. For example, Microsoft Internet Explorer 5.0 and later support the _search target value.
The property is rendered as a target attribute. The target attribute on anchor elements is not allowed in the XHTML 1.1 strict document type definition. Do not set the property if the rendered output for the must be XHTML 1.1-compliant. For more information, see ASP.NET and XHTML Compliance.
When creating accessible Web pages, it is strongly recommended you avoid using the property to target another window. For more information, see ASP.NET Accessibility.
Gets or sets the target window or frame in which to display the Web page content associated with a menu item.
2.0.0.0
Property
System.ComponentModel.DefaultValue("")
System.ComponentModel.Localizable(true)
System.String
To be added.
Use the property to specify or determine the text that is displayed for the menu item in the control.
If the property contains null, the get accessor returns the value of the property. If the property, in turn, contains null, is returned.
The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.
Gets or sets the text displayed for the menu item in a control.
2.0.0.0
Property
System.ComponentModel.DefaultValue("")
System.ComponentModel.Localizable(true)
System.String
To be added.
Use the property to specify the ToolTip text for the menu item. The ToolTip text is displayed when the mouse pointer is positioned over the menu item.
The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.
Gets or sets the ToolTip text for the menu item.
2.0.0.0
Property
System.ComponentModel.DefaultValue("")
System.ComponentModel.Localizable(true)
System.String
To be added.
The property is used to supplement the property by storing any additional data associated with the menu item. This value is not displayed in the control and is commonly used to store data for handling postback events.
If the property contains null, the get accessor returns the value of the property. If the property, in turn, contains null, is returned.
The value of the property is also used when the value path specified in the property is generated. A value path is a delimiter-separated list of menu item values that forms a path from the root menu item to the current menu item. The value path is used to indicate the position of a menu item in a control.
Menu items at the same menu level must each have a unique value for the property; the control cannot distinguish between different menu items at the same level that have the same value.
The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.
Gets or sets a non-displayed value used to store any additional data about the menu item, such as data used for handling postback events.
2.0.0.0
Property
System.ComponentModel.Browsable(false)
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
System.String
To be added.
The property contains a delimiter-separated list of menu item values that form a path from the root menu item to the current menu item. The value path is used to indicate the position of a menu item in a control. You can specify the delimiter character used to separate the menu item values by using the property. This value is commonly used when parsing the list for the individual values, or to pass as an argument to the method of the class. Depending on the value displayed in the control, the delimiter character might need to be changed to prevent any conflicts. For example, if you set the delimiter character to a comma, the displayed value should not contain any commas; otherwise, you cannot accurately parse the property.
The values of the property of each menu item from the root menu item to the current menu item are used to generate the value path. Menu items at the same menu level must each have a unique value for the property; the control cannot distinguish between different menu items at the same level that have the same value.
Gets the path from the root menu item to the current menu item.
2.0.0.0