System.Web.UI.WebControls Namespace MenuItem Class
.NET Framework version 2.0
Sets or retrieves the value associated with a MenuItem.
Inline |
<asp:menuitem value = strValue ... > |
Script |
MenuItem.Value = strValue |
strValue |
The value associated with a MenuItem. |
The property is read/write with no default value.
Use the Value property to specify or determine the value associated with a MenuItem.
The Value property is used to supplement the Text 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 that is to be passed on to the appropriate event handler on postback.
NOTE: If no Value is specified for the menu item, this property returns the value of the Text property. If the Text property in turn contains a null reference, an empty string is returned.
The value of the Value property is also used when the ValuePath 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 Menu control.
NOTE: Menu items at the same menu level must each have a unique value for the Value property; the Menu control cannot distinguish between different menu items at the same level that have the same value.
The following example demonstrates how to programmatically determine the given Value for a menu item and its parent, when the user selects an item from a Menu control.
Note that this example merely serves to illustrate the concept. If all you need is to determine the selected menu item's Value, simply use the Menu.SelectedValue property instead, without having to code a handler for the MenuItemClick event.
Show me
MenuItem Members Text SelectedValue