Export (0) Print
Expand All

Menu Class

Displays a menu in an ASP.NET Web page.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[ControlValuePropertyAttribute(L"SelectedValue")]
public ref class Menu : public HierarchicalDataBoundControl, 
	IPostBackEventHandler, INamingContainer
<asp:Menu />

The Menu type exposes the following members.

  NameDescription
Public methodMenuInitializes a new instance of the Menu class.
Top

  NameDescription
Public propertyAccessKeyGets or sets the access key that allows you to quickly navigate to the Web server control. (Inherited from WebControl.)
Protected propertyAdapterGets the browser-specific adapter for the control. (Inherited from Control.)
Public propertyAppRelativeTemplateSourceDirectoryGets or sets the application-relative virtual directory of the Page or UserControl object that contains this control. (Inherited from Control.)
Public propertyAttributesGets the collection of arbitrary attributes (for rendering only) that do not correspond to properties on the control. (Inherited from WebControl.)
Public propertyBackColorGets or sets the background color of the Web server control. (Inherited from WebControl.)
Public propertyBindingContainerInfrastructure. Gets the control that contains this control's data binding. (Inherited from Control.)
Public propertyBorderColorGets or sets the border color of the Web control. (Inherited from WebControl.)
Public propertyBorderStyleGets or sets the border style of the Web server control. (Inherited from WebControl.)
Public propertyBorderWidthGets or sets the border width of the Web server control. (Inherited from WebControl.)
Protected propertyChildControlsCreatedGets a value that indicates whether the server control's child controls have been created. (Inherited from Control.)
Public propertyClientIDGets the control ID for HTML markup that is generated by ASP.NET. (Inherited from Control.)
Public propertyClientIDModeGets or sets the algorithm that is used to generate the value of the ClientID property. (Inherited from Control.)
Protected propertyClientIDSeparatorGets a character value representing the separator character used in the ClientID property. (Inherited from Control.)
Protected propertyContextGets the HttpContext object associated with the server control for the current Web request. (Inherited from Control.)
Public propertyControlsGets a ControlCollection that contains the child controls of the Menu control. (Overrides Control::Controls.)
Public propertyControlStyleGets the style of the Web server control. This property is used primarily by control developers. (Inherited from WebControl.)
Public propertyControlStyleCreatedGets a value indicating whether a Style object has been created for the ControlStyle property. This property is primarily used by control developers. (Inherited from WebControl.)
Public propertyCssClassGets or sets the Cascading Style Sheet (CSS) class rendered by the Web server control on the client. (Inherited from WebControl.)
Public propertyDataBindingsGets a collection of MenuItemBinding objects that define the relationship between a data item and the menu item it is binding to.
Public propertyDataItemContainerGets a reference to the naming container if the naming container implements IDataItemContainer. (Inherited from Control.)
Public propertyDataKeysContainerGets a reference to the naming container if the naming container implements IDataKeysControl. (Inherited from Control.)
Public propertyDataSourceGets or sets the object from which the data-bound control retrieves its list of data items. (Inherited from BaseDataBoundControl.)
Public propertyDataSourceIDGets or sets the ID of the control from which the data-bound control retrieves its list of data items. (Inherited from HierarchicalDataBoundControl.)
Protected propertyDesignModeGets a value indicating whether a control is being used on a design surface. (Inherited from Control.)
Public propertyDisappearAfterGets or sets the duration for which a dynamic menu is displayed after the mouse pointer is no longer positioned over the menu.
Public propertyDynamicBottomSeparatorImageUrlGets or sets the URL to an image to display at the bottom of each dynamic menu item to separate it from other menu items.
Public propertyDynamicEnableDefaultPopOutImageGets or sets a value indicating whether the built-in image that indicates that a dynamic menu item has a submenu is displayed.
Public propertyDynamicHorizontalOffsetGets or sets the number of pixels to shift a dynamic menu horizontally relative to its parent menu item.
Public propertyDynamicHoverStyleGets a reference to the Style object that allows you to set the appearance of a dynamic menu item when the mouse pointer is positioned over it.
Public propertyDynamicItemFormatStringGets or sets additional text shown with all menu items that are dynamically displayed.
Public propertyDynamicItemTemplateGets or sets the template that contains the custom content to render for a dynamic menu.
Public propertyDynamicMenuItemStyleGets a reference to the MenuItemStyle object that allows you to set the appearance of the menu items within a dynamic menu.
Public propertyDynamicMenuStyleGets a reference to the MenuItemStyle object that allows you to set the appearance of a dynamic menu.
Public propertyDynamicPopOutImageTextFormatStringGets or sets the alternate text for the image used to indicate that a dynamic menu item has a submenu.
Public propertyDynamicPopOutImageUrlGets or sets the URL to a custom image that is displayed in a dynamic menu item when the dynamic menu item has a submenu.
Public propertyDynamicSelectedStyleGets a reference to the MenuItemStyle object that allows you to set the appearance of the dynamic menu item selected by the user.
Public propertyDynamicTopSeparatorImageUrlGets or sets the URL to an image to display at the top of each dynamic menu item to separate it from other menu items.
Public propertyDynamicVerticalOffsetGets or sets the number of pixels to shift a dynamic menu vertically relative to its parent menu item.
Public propertyEnabledGets or sets a value indicating whether the Web server control is enabled. (Inherited from WebControl.)
Public propertyEnableThemingGets or sets a value indicating whether themes apply to this control. (Inherited from WebControl.)
Public propertyEnableViewStateGets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client. (Inherited from Control.)
Protected propertyEventsGets a list of event handler delegates for the control. This property is read-only. (Inherited from Control.)
Public propertyFontGets the font properties associated with the Web server control. (Inherited from WebControl.)
Public propertyForeColorGets or sets the foreground color (typically the color of the text) of the Web server control. (Inherited from WebControl.)
Public propertyHasAttributesGets a value indicating whether the control has attributes set. (Inherited from WebControl.)
Protected propertyHasChildViewStateGets a value indicating whether the current server control's child controls have any saved view-state settings. (Inherited from Control.)
Public propertyHeightGets or sets the height of the Web server control. (Inherited from WebControl.)
Public propertyIDGets or sets the programmatic identifier assigned to the server control. (Inherited from Control.)
Protected propertyIdSeparatorInfrastructure. Gets the character used to separate control identifiers. (Inherited from Control.)
Public propertyIncludeStyleBlockGets or sets a value that indicates whether ASP.NET should render a block of cascading style sheet (CSS) definitions for the styles that are used in the menu.
Protected propertyInitializedGets a value indicating whether the data-bound control has been initialized. (Inherited from BaseDataBoundControl.)
Protected propertyIsBoundUsingDataSourceIDGets a value indicating whether the DataSourceID property is set. (Inherited from BaseDataBoundControl.)
Protected propertyIsChildControlStateClearedGets a value indicating whether controls contained within this control have control state. (Inherited from Control.)
Protected propertyIsDataBindingAutomaticGets a value that indicates whether data binding is automatic. (Inherited from BaseDataBoundControl.)
Protected propertyIsEnabledGets a value indicating whether the control is enabled. (Inherited from WebControl.)
Protected propertyIsTrackingViewStateGets a value that indicates whether the server control is saving changes to its view state. (Inherited from Control.)
Protected propertyIsUsingModelBindersWhen implemented in a derived class, gets a value that indicates whether the control is using model binders. (Inherited from BaseDataBoundControl.)
Protected propertyIsViewStateEnabledGets a value indicating whether view state is enabled for this control. (Inherited from Control.)
Public propertyItemsGets a MenuItemCollection object that contains all menu items in the Menu control.
Public propertyItemWrapGets or sets a value indicating whether the text for menu items should wrap.
Public propertyLevelMenuItemStylesGets a MenuItemStyleCollection object that contains the style settings that are applied to menu items based on their level in a Menu control.
Public propertyLevelSelectedStylesGets a MenuItemStyleCollection object that contains the style settings that are applied to the selected menu item based on its level in a Menu control.
Public propertyLevelSubMenuStylesGets a MenuItemStyleCollection object that contains the style settings that are applied to the submenu items in the static menu based on their level in a Menu control.
Protected propertyLoadViewStateByIDGets a value indicating whether the control participates in loading its view state by ID instead of index. (Inherited from Control.)
Public propertyMaximumDynamicDisplayLevelsGets or sets the number of menu levels to render for a dynamic menu.
Public propertyNamingContainerGets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same Control::ID property value. (Inherited from Control.)
Public propertyOrientationGets or sets the direction in which to render the Menu control.
Public propertyPageGets a reference to the Page instance that contains the server control. (Inherited from Control.)
Public propertyParentGets a reference to the server control's parent control in the page control hierarchy. (Inherited from Control.)
Public propertyPathSeparatorGets or sets the character used to delimit the path of a menu item in a Menu control.
Public propertyRenderingCompatibilityGets a value that specifies the ASP.NET version that rendered HTML will be compatible with. (Inherited from Control.)
Public propertyRenderingModeGets or sets a value that specifies whether the Menu control renders HTML table elements and inline styles, or listitem elements and cascading style sheet (CSS) styles.
Protected propertyRequiresDataBindingGets or sets a value indicating whether the DataBind method should be called. (Inherited from BaseDataBoundControl.)
Public propertyScrollDownImageUrlGets or sets the URL to an image displayed in a dynamic menu to indicate that the user can scroll down for additional menu items.
Public propertyScrollDownTextGets or sets the alternate text for the image specified in the ScrollDownImageUrl property.
Public propertyScrollUpImageUrlGets or sets the URL to an image displayed in a dynamic menu to indicate that the user can scroll up for additional menu items.
Public propertyScrollUpTextGets or sets the alternate text for the image specified in the ScrollUpImageUrl property.
Public propertySelectedItemGets the selected menu item.
Public propertySelectedValueGets the value of the selected menu item.
Public propertySiteGets information about the container that hosts the current control when rendered on a design surface. (Inherited from Control.)
Public propertySkinIDGets or sets the skin to apply to the control. (Inherited from WebControl.)
Public propertySkipLinkTextGets or sets the alternate text for a hidden image read by screen readers to provide the ability to skip the list of links.
Public propertyStaticBottomSeparatorImageUrlGets or sets the URL to an image displayed as the separator at the bottom of each static menu item.
Public propertyStaticDisplayLevelsGets or sets the number of menu levels to display in a static menu.
Public propertyStaticEnableDefaultPopOutImageGets or sets a value indicating whether the built-in image is displayed to indicate that a static menu item has a submenu.
Public propertyStaticHoverStyleGets a reference to the Style object that allows you to set the appearance of a static menu item when the mouse pointer is positioned over it.
Public propertyStaticItemFormatStringGets or sets additional text shown with all menu items that are statically displayed.
Public propertyStaticItemTemplateGets or sets the template that contains the custom content to render for a static menu.
Public propertyStaticMenuItemStyleGets a reference to the MenuItemStyle object that allows you to set the appearance of the menu items in a static menu.
Public propertyStaticMenuStyleGets a reference to the MenuItemStyle object that allows you to set the appearance of a static menu.
Public propertyStaticPopOutImageTextFormatStringGets or sets the alternate text for the pop-out image used to indicate that a static menu item has a submenu.
Public propertyStaticPopOutImageUrlGets or sets the URL to an image displayed to indicate that a static menu item has a submenu.
Public propertyStaticSelectedStyleGets a reference to the MenuItemStyle object that allows you to set the appearance of the menu item selected by the user in a static menu.
Public propertyStaticSubMenuIndentGets or sets the amount of space, in pixels, to indent submenus within a static menu.
Public propertyStaticTopSeparatorImageUrlGets or sets the URL to an image displayed as the separator at the top of each static menu item.
Public propertyStyleGets a collection of text attributes that will be rendered as a style attribute on the outer tag of the Web server control. (Inherited from WebControl.)
Public propertySupportsDisabledAttributeGets a value that indicates whether the control should set the disabled attribute of the rendered HTML element to "disabled" when the control's IsEnabled property is false. (Inherited from BaseDataBoundControl.)
Public propertyTabIndexGets or sets the tab index of the Web server control. (Inherited from WebControl.)
Protected propertyTagKeyGets the HtmlTextWriterTag value that corresponds to a Menu control. This property is used primarily by control developers. (Overrides WebControl::TagKey.)
Protected propertyTagNameGets the name of the control tag. This property is used primarily by control developers. (Inherited from WebControl.)
Public propertyTargetGets or sets the target window or frame in which to display the Web page content associated with a menu item.
Public propertyTemplateControlGets or sets a reference to the template that contains this control. (Inherited from Control.)
Public propertyTemplateSourceDirectoryGets the virtual directory of the Page or UserControl that contains the current server control. (Inherited from Control.)
Public propertyToolTipGets or sets the text displayed when the mouse pointer hovers over the Web server control. (Inherited from WebControl.)
Public propertyUniqueIDGets the unique, hierarchically qualified identifier for the server control. (Inherited from Control.)
Public propertyValidateRequestModeGets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values. (Inherited from Control.)
Protected propertyViewStateGets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page. (Inherited from Control.)
Protected propertyViewStateIgnoresCaseGets a value that indicates whether the StateBag object is case-insensitive. (Inherited from Control.)
Public propertyViewStateModeGets or sets the view-state mode of this control. (Inherited from Control.)
Public propertyVisibleGets or sets a value that indicates whether a server control is rendered as UI on the page. (Inherited from Control.)
Public propertyWidthGets or sets the width of the Web server control. (Inherited from WebControl.)
Top

  NameDescription
Protected methodAddAttributesToRenderAdds HTML attributes and styles that need to be rendered to the specified HtmlTextWriter object. (Overrides WebControl::AddAttributesToRender(HtmlTextWriter).)
Protected methodAddedControlCalled after a child control is added to the Controls collection of the Control object. (Inherited from Control.)
Protected methodAddParsedSubObjectNotifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object. (Inherited from Control.)
Public methodApplyStyleCopies any nonblank elements of the specified style to the Web control, overwriting any existing style elements of the control. This method is primarily used by control developers. (Inherited from WebControl.)
Public methodApplyStyleSheetSkinApplies the style properties defined in the page style sheet to the control. (Inherited from Control.)
Protected methodBeginRenderTracingBegins design-time tracing of rendering data. (Inherited from Control.)
Protected methodBuildProfileTreeInfrastructure. Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page. (Inherited from Control.)
Protected methodClearCachedClientIDInfrastructure. Sets the cached ClientID value to nullptr. (Inherited from Control.)
Protected methodClearChildControlStateDeletes the control-state information for the server control's child controls. (Inherited from Control.)
Protected methodClearChildStateDeletes the view-state and control-state information for all the server control's child controls. (Inherited from Control.)
Protected methodClearChildViewStateDeletes the view-state information for all the server control's child controls. (Inherited from Control.)
Protected methodClearEffectiveClientIDModeInfrastructure. Sets the ClientIDMode property of the current control instance and of any child controls to Inherit. (Inherited from Control.)
Protected methodConfirmInitStateSets the initialized state of the data-bound control. (Inherited from BaseDataBoundControl.)
Public methodCopyBaseAttributesCopies the properties not encapsulated by the Style object from the specified Web server control to the Web server control that this method is called from. This method is used primarily by control developers. (Inherited from WebControl.)
Protected methodCreateChildControlsCreates the child controls of a Menu control. (Overrides Control::CreateChildControls().)
Protected methodCreateControlCollectionCreates a new ControlCollection object to hold the child controls (both literal and server) of the server control. (Inherited from Control.)
Protected methodCreateControlStyleCreates the style object that is used internally by the WebControl class to implement all style related properties. This method is used primarily by control developers. (Inherited from WebControl.)
Public methodDataBind()Binds the data source to the Menu control. This method cannot be inherited. (Overrides BaseDataBoundControl::DataBind().)
Protected methodDataBind(Boolean)Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event. (Inherited from Control.)
Protected methodDataBindChildrenBinds a data source to the server control's child controls. (Inherited from Control.)
Public methodDisposeEnables a server control to perform final clean up before it is released from memory. (Inherited from Control.)
Protected methodEndRenderTracingEnds design-time tracing of rendering data. (Inherited from Control.)
Protected methodEnsureChildControlsDetermines whether the server control contains child controls. If it does not, it creates child controls. (Inherited from Control.)
Protected methodEnsureDataBoundVerifies that the menu control requires data binding and that a valid data source control is specified before calling the DataBind method. (Overrides BaseDataBoundControl::EnsureDataBound().)
Protected methodEnsureIDCreates an identifier for controls that do not have an identifier assigned. (Inherited from Control.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindControl(String)Searches the current naming container for a server control with the specified id parameter. (Inherited from Control.)
Protected methodFindControl(String, Int32)Infrastructure. Searches the current naming container for a server control with the specified id and an integer, specified in the pathOffset parameter, which aids in the search. You should not override this version of the FindControl method. (Inherited from Control.)
Public methodFindItemRetrieves the menu item at the specified value path.
Public methodFocusSets input focus to a control. (Inherited from Control.)
Protected methodGetDataRetrieves a HierarchicalDataSourceView object that the data-bound control uses to perform data operations. (Inherited from HierarchicalDataBoundControl.)
Protected methodGetDataSourceRetrieves the IHierarchicalDataSource that the data-bound control is associated with, if any. (Inherited from HierarchicalDataBoundControl.)
Protected methodGetDesignModeStateRetrieves the design-time state of the Menu control. (Overrides Control::GetDesignModeState().)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetRouteUrl(Object)Gets the URL that corresponds to a set of route parameters. (Inherited from Control.)
Public methodGetRouteUrl(RouteValueDictionary)Gets the URL that corresponds to a set of route parameters. (Inherited from Control.)
Public methodGetRouteUrl(String, Object)Gets the URL that corresponds to a set of route parameters and a route name. (Inherited from Control.)
Public methodGetRouteUrl(String, RouteValueDictionary)Gets the URL that corresponds to a set of route parameters and a route name. (Inherited from Control.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetUniqueIDRelativeToReturns the prefixed portion of the UniqueID property of the specified control. (Inherited from Control.)
Public methodHasControlsDetermines if the server control contains any child controls. (Inherited from Control.)
Protected methodHasEventsReturns a value indicating whether events are registered for the control or any child controls. (Inherited from Control.)
Protected methodIsLiteralContentInfrastructure. Determines if the server control holds only literal content. (Inherited from Control.)
Protected methodLoadControlStateLoads the state of the properties in the Menu control that need to be persisted. (Overrides Control::LoadControlState(Object).)
Protected methodLoadViewStateLoads the previously saved view state of the Menu control. (Overrides WebControl::LoadViewState(Object).)
Protected methodMapPathSecureRetrieves the physical path that a virtual path, either absolute or relative, maps to. (Inherited from Control.)
Protected methodMarkAsDataBoundSets the state of the control in view state as successfully bound to data. (Inherited from HierarchicalDataBoundControl.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodMergeStyleCopies any nonblank elements of the specified style to the Web control, but will not overwrite any existing style elements of the control. This method is used primarily by control developers. (Inherited from WebControl.)
Protected methodOnBubbleEventInfrastructure. Determines whether the event for the Menu control is passed up the page's user interface (UI) server control hierarchy. (Overrides Control::OnBubbleEvent(Object, EventArgs).)
Protected methodOnDataBindingRaises the DataBinding event. (Overrides Control::OnDataBinding(EventArgs).)
Protected methodOnDataBoundRaises the DataBound event. (Inherited from BaseDataBoundControl.)
Protected methodOnDataPropertyChangedCalled when one of the base data source identification properties is changed, to re-bind the data-bound control to its data. (Inherited from HierarchicalDataBoundControl.)
Protected methodOnDataSourceChangedCalled when the IHierarchicalDataSource instance that the data-bound control works with raises the DataSourceChanged event. (Inherited from HierarchicalDataBoundControl.)
Protected methodOnInitInfrastructure. Raises the Init event. (Overrides BaseDataBoundControl::OnInit(EventArgs).)
Protected methodOnLoadHandles the Load event. (Inherited from HierarchicalDataBoundControl.)
Protected methodOnMenuItemClickRaises the MenuItemClick event.
Protected methodOnMenuItemDataBoundRaises the MenuItemDataBound event.
Protected methodOnPagePreLoadSets the initialized state of the data-bound control before the control is loaded. (Inherited from HierarchicalDataBoundControl.)
Protected methodOnPreRenderInfrastructure. Raises the PreRender event. (Overrides BaseDataBoundControl::OnPreRender(EventArgs).)
Protected methodOnUnloadRaises the Unload event. (Inherited from Control.)
Protected methodOpenFileGets a Stream used to read a file. (Inherited from Control.)
Protected methodPerformDataBindingInfrastructure. Binds the items from the data source to the menu items in the Menu control. (Overrides HierarchicalDataBoundControl::PerformDataBinding().)
Protected methodPerformSelectRetrieves data from the associated data source. (Inherited from HierarchicalDataBoundControl.)
Protected methodRaiseBubbleEventAssigns any sources of the event and its information to the control's parent. (Inherited from Control.)
Protected methodRaisePostBackEventProcesses an event raised when a form is posted to the server.
Protected methodRemovedControlCalled after a child control is removed from the Controls collection of the Control object. (Inherited from Control.)
Protected methodRenderInfrastructure. Renders the menu control on the client browser. (Overrides WebControl::Render(HtmlTextWriter).)
Public methodRenderBeginTagAdds tag attributes and writes the markup for the opening tag of the control to the output stream emitted to the browser or device. (Overrides WebControl::RenderBeginTag(HtmlTextWriter).)
Protected methodRenderChildrenOutputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client. (Inherited from Control.)
Protected methodRenderContentsInfrastructure. This member overrides RenderContents. (Overrides WebControl::RenderContents(HtmlTextWriter).)
Public methodRenderControl(HtmlTextWriter)Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled. (Inherited from Control.)
Protected methodRenderControl(HtmlTextWriter, ControlAdapter)Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object. (Inherited from Control.)
Public methodRenderEndTagPerforms final markup and writes the HTML closing tag of the control to the output stream emitted to the browser or device. (Overrides WebControl::RenderEndTag(HtmlTextWriter).)
Protected methodResolveAdapterGets the control adapter responsible for rendering the specified control. (Inherited from Control.)
Public methodResolveClientUrlGets a URL that can be used by the browser. (Inherited from Control.)
Public methodResolveUrlConverts a URL into one that is usable on the requesting client. (Inherited from Control.)
Protected methodSaveControlStateInfrastructure. Saves the state of the properties in the Menu control that need to be persisted. (Overrides Control::SaveControlState().)
Protected methodSaveViewStateSaves the state of the Menu control. (Overrides WebControl::SaveViewState().)
Protected methodSetDesignModeStateSets design-time data for the Menu control. (Overrides Control::SetDesignModeState(IDictionary).)
Protected methodSetItemDataBoundSets the DataBound property of the specified MenuItem object with the specified value.
Protected methodSetItemDataItemSets the DataItem property of the specified MenuItem object with the specified value.
Protected methodSetItemDataPathSets the DataPath property of the specified MenuItem object with the specified value.
Public methodSetRenderMethodDelegateInfrastructure. Assigns an event handler delegate to render the server control and its content into its parent control. (Inherited from Control.)
Public methodSetTraceData(Object, Object)Sets trace data for design-time tracing of rendering data, using the trace data key and the trace data value. (Inherited from Control.)
Public methodSetTraceData(Object, Object, Object)Sets trace data for design-time tracing of rendering data, using the traced object, the trace data key, and the trace data value. (Inherited from Control.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodTrackViewStateTracks view-state changes to the Menu control so they can be stored in the control's StateBag object. This object is accessible through the ViewState property. (Overrides WebControl::TrackViewState().)
Protected methodValidateDataSourceVerifies that the object a data-bound control binds to is one it can work with. (Inherited from HierarchicalDataBoundControl.)
Top

  NameDescription
Public eventDataBindingOccurs when the server control binds to a data source. (Inherited from Control.)
Public eventDataBoundOccurs after the server control binds to a data source. (Inherited from BaseDataBoundControl.)
Public eventDisposedOccurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested. (Inherited from Control.)
Public eventInitOccurs when the server control is initialized, which is the first step in its lifecycle. (Inherited from Control.)
Public eventLoadOccurs when the server control is loaded into the Page object. (Inherited from Control.)
Public eventMenuItemClickOccurs when a menu item in a Menu control is clicked.
Public eventMenuItemDataBoundOccurs when a menu item in a Menu control is bound to data.
Public eventPreRenderOccurs after the Control object is loaded but prior to rendering. (Inherited from Control.)
Public eventUnloadOccurs when the server control is unloaded from memory. (Inherited from Control.)
Top

  NameDescription
Public Extension MethodEnableDynamicData(Type)Overloaded. Enables Dynamic Data behavior for the specified data control. (Defined by DataControlExtensions.)
Public Extension MethodEnableDynamicData(Type, Object)Overloaded. Enables Dynamic Data behavior for the specified data control. (Defined by DataControlExtensions.)
Public Extension MethodEnableDynamicData(Type, IDictionary<String, Object>)Overloaded. Enables Dynamic Data behavior for the specified data control. (Defined by DataControlExtensions.)
Public Extension MethodEnablePersistedSelectionEnables selection to be persisted in data controls that support selection and paging. (Defined by DynamicDataExtensions.)
Public Extension MethodFindDataSourceControlReturns the data source that is associated with the data control for the specified control. (Defined by DynamicDataExtensions.)
Public Extension MethodFindFieldTemplateReturns the field template for the specified column in the specified control's naming container. (Defined by DynamicDataExtensions.)
Public Extension MethodFindMetaTableReturns the metatable object for the containing data control. (Defined by DynamicDataExtensions.)
Public Extension MethodGetDefaultValuesGets the collection of the default values for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodGetMetaTableGets the table metadata for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodSetMetaTable(MetaTable)Overloaded. Sets the table metadata for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodSetMetaTable(MetaTable, IDictionary<String, Object>)Overloaded. Sets the table metadata and default value mapping for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodSetMetaTable(MetaTable, Object)Overloaded. Sets the table metadata and default value mapping for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodTryGetMetaTableDetermines whether table metadata is available. (Defined by DynamicDataExtensions.)
Top

  NameDescription
Public fieldStatic memberMenuItemClickCommandNameContains the command name.
Top

  NameDescription
Explicit interface implemetationPrivate methodIAttributeAccessor::GetAttributeInfrastructure. Gets an attribute of the Web control with the specified name. (Inherited from WebControl.)
Explicit interface implemetationPrivate methodIAttributeAccessor::SetAttributeSets an attribute of the Web control to the specified name and value. (Inherited from WebControl.)
Explicit interface implemetationPrivate propertyIControlBuilderAccessor::ControlBuilderFor a description of this member, see IControlBuilderAccessor::ControlBuilder. (Inherited from Control.)
Explicit interface implemetationPrivate methodIControlDesignerAccessor::GetDesignModeStateFor a description of this member, see IControlDesignerAccessor::GetDesignModeState. (Inherited from Control.)
Explicit interface implemetationPrivate methodIControlDesignerAccessor::SetDesignModeStateFor a description of this member, see IControlDesignerAccessor::SetDesignModeState. (Inherited from Control.)
Explicit interface implemetationPrivate methodIControlDesignerAccessor::SetOwnerControlInfrastructure. For a description of this member, see IControlDesignerAccessor::SetOwnerControl. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIControlDesignerAccessor::UserDataFor a description of this member, see IControlDesignerAccessor::UserData. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIDataBindingsAccessor::DataBindingsFor a description of this member, see IDataBindingsAccessor::DataBindings. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIDataBindingsAccessor::HasDataBindingsFor a description of this member, see IDataBindingsAccessor::HasDataBindings. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIExpressionsAccessor::ExpressionsFor a description of this member, see IExpressionsAccessor::Expressions. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIExpressionsAccessor::HasExpressionsFor a description of this member, see IExpressionsAccessor::HasExpressions. (Inherited from Control.)
Explicit interface implemetationPrivate methodIParserAccessor::AddParsedSubObjectFor a description of this member, see IParserAccessor::AddParsedSubObject. (Inherited from Control.)
Explicit interface implemetationPrivate methodIPostBackEventHandler::RaisePostBackEventInfrastructure. Processes an event raised when a form is posted to the server.
Top

In this topic:

Introduction

The Menu control is used to display a menu in an ASP.NET Web page and is often used in combination with a SiteMapDataSource control for navigating a Web site. The Menu control supports the following features:

  • Data binding that allows the control's menu items to be bound to hierarchal data sources.

  • Site navigation through integration with the SiteMapDataSource control.

  • Programmatic access to the Menu object model to dynamically create menus, populate menu items, set properties, and so on.

  • Customizable appearance through themes, user-defined images, styles, and user-defined templates.

When the user clicks a menu item, the Menu control can either navigate to a linked Web page or simply post back to the server. If the NavigateUrl property of a menu item is set, the Menu 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 Menu control. To display the linked content in a different window or frame, use the Target property of the Menu control.

NoteNote

The Target property affects every menu item in the control. To specify a window or frame for an individual menu item, set the Target property of the MenuItem object directly.

The Menu control displays two types of menus: a static menu and a dynamic menu. The static menu is always displayed in a Menu control. By default, the menu items at the root level (level 0) are displayed in the static menu. You can display additional menu levels (static submenus) within the static menu by setting the StaticDisplayLevels property. Menu items (if any) with a higher level than the value specified by the StaticDisplayLevels property are displayed in a dynamic menu. A dynamic menu appears only when the user positions the mouse pointer over the parent menu item that contains a dynamic submenu. Dynamic menus automatically disappear after a certain duration. Use the DisappearAfter property to specify the duration.

NoteNote

A dynamic menu also disappears when the user clicks outside of the menu.

You can also limit the number of levels displayed in a dynamic menu by setting the MaximumDynamicDisplayLevels property. Menu levels higher than the specified value are discarded.

NoteNote

The Menu control is not designed to be used inside an UpdatePanel control. You can add the Menu control only to a page outside an UpdatePanel control. UpdatePanel controls are used to update selected regions of a page instead of updating the whole page with a postback. For more information, see UpdatePanel Control Overview and Partial-Page Rendering Overview.

Menu Items

A Menu control is made up of a tree of menu items represented by MenuItem objects. Menu items at the top level (level 0) are called root menu items. A menu item that has a parent menu item is called a child menu item. All root menu items are stored in the Items collection. Child menu items are stored in a parent menu item's ChildItems collection.

Each menu item has a Text and a Value property. The value of the Text property is displayed in the Menu control, while the Value 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. When clicked, a menu item can navigate to another Web page indicated by the NavigateUrl property.

NoteNote

If the NavigateUrl property is not set for a menu item, the Menu control simply submits the page to the server for processing when the menu item is clicked.

You can also optionally display an image in a menu item by setting the ImageUrl property.

For more information on menu items, see MenuItem.

Static Data

The simplest data model of the Menu control is static menu items. To display static menu items using declarative syntax, first nest opening and closing <Items> tags between the opening and closing tags of the Menu control. Next, create the menu structure by nesting <asp:MenuItem> elements between the opening and closing <Items> tags. Each <asp:MenuItem> element represents a menu item in the control and maps to a MenuItem object. You can set the properties of each menu item by setting the attributes of its <asp:MenuItem> element. To create submenu items, nest additional <asp:MenuItem> elements between the opening and closing <asp:MenuItem> tags of the parent menu item.

Binding to Data

The Menu control can use any hierarchal data source control, such as an XmlDataSource control or a SiteMapDataSource control. To bind to a hierarchal data source control, set the DataSourceID property of the Menu control to the ID value of the data source control. The Menu control automatically binds to the specified data source control. This is the preferred method to bind to data.

When binding to a data source where each data item contains multiple properties (such as an XML element with several attributes), a menu item displays the value returned by the ToString method of the data item by default. In the case of an XML element, the menu item displays the element name, which shows the underlying structure of the menu tree but is not very useful otherwise. You can bind a menu item to a specific data item property by using the DataBindings collection to specify menu item bindings. The DataBindings collection contains MenuItemBinding objects that define the relationship between a data item and the menu item it is binding to. You can specify the criteria for binding and the data item property to display in the node. For more information on menu item bindings, see MenuItemBinding.

You cannot create empty nodes in a Menu control by setting the Text or TextField properties to the empty string (""). Setting these properties to the empty string has the same effect as not setting the properties. In that case, the Menu control creates a default binding using the DataSource property. For more information, see Binding to Databases.

Customizing the User Interface

There are many ways to customize the appearance of the Menu control. First, you can specify whether the Menu control is rendered horizontally or vertically by setting the Orientation property. You can also specify a different style (such as font size and color) for each of the menu item types.

If you use cascading style sheets (CSS) to customize the appearance of the control, use either inline styles or a separate CSS file, but not both. Using both inline styles and a separate CSS file could cause unexpected results. For more information on using style sheets with controls, see ASP.NET Web Server Controls and CSS Styles.

The following table lists the available menu item styles.

Menu item style property

Description

DynamicHoverStyle

The style settings for a dynamic menu item when the mouse pointer is positioned over it.

DynamicMenuItemStyle

The style settings for an individual dynamic menu item.

DynamicMenuStyle

The style settings for a dynamic menu.

DynamicSelectedStyle

The style settings for the currently selected dynamic menu item.

StaticHoverStyle

The style settings for a static menu item when the mouse pointer is positioned over it.

StaticMenuItemStyle

The style settings for an individual static menu item.

StaticMenuStyle

The style settings for a static menu.

StaticSelectedStyle

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 following style collections.

Level style collections

Description

LevelMenuItemStyles

A collection of MenuItemStyle objects that control the style of the menu items on a level basis.

LevelSelectedStyles

A collection of MenuItemStyle objects that control the style of selected menu items on a level basis.

LevelSubMenuStyles

A collection of MenuItemStyle objects that control the style of the submenu items on a level basis.

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.

NoteNote

If you use any of the level style collections listed in the previous table to define the style for the Menu control, these style settings override the individual menu item style properties.

Another way to alter the appearance of the control is to customize the images displayed in the Menu control. You can specify your own custom image for the different parts of the control by setting the properties shown in the following table.

Image property

Description

DynamicBottomSeparatorImageUrl

An optional image displayed at the bottom of a dynamic menu item to separate it from other menu items.

DynamicPopOutImageUrl

An optional image displayed in a dynamic menu item to indicate that it has a submenu.

DynamicTopSeparatorImageUrl

An optional image displayed at the top of a dynamic menu item to separate it from other menu items.

ScrollDownImageUrl

The image displayed at the bottom of a menu item to indicate that the user can scroll down to view additional menu items.

ScrollUpImageUrl

The image displayed at the top of a menu item to indicate that the user can scroll up to view additional menu items.

StaticBottomSeparatorImageUrl

An optional image displayed at the bottom of a static menu item to separate it from other menu items.

StaticPopOutImageUrl

An optional image displayed in a static menu item to indicate that it has a submenu.

StaticTopSeparatorImageUrl

An optional image displayed at the top of a static menu item to separate it from other menu items.

For complete control of the user interface (UI), you can define your own custom templates for the Menu control using the following template properties.

Template property

Description

DynamicItemTemplate

The template that contains the custom content to render for a dynamic menu item.

StaticItemTemplate

The template that contains the custom content to render for a static menu item.

You can control the vertical and horizontal position of a dynamic menu relative to its parent menu item by setting the DynamicVerticalOffset and DynamicHorizontalOffset properties, respectively. To control the indentation of the static submenu items within a static menu, use the StaticSubMenuIndent property.

Events

The Menu control provides several events that you can program against. This allows you to run a custom routine whenever an event occurs. The following table lists the supported events.

Event

Description

MenuItemClick

Occurs when a menu item is clicked. This event is commonly used to synchronize a Menu control with another control on the page.

MenuItemDataBound

Occurs when a menu item is bound to data. This event is commonly used to modify a menu item before it is rendered in a Menu control.

Accessibility

For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio and ASP.NET and ASP.NET Controls and Accessibility.

Declarative Syntax

<asp:Menu
    AccessKey="string"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
        Inset|Outset"
    BorderWidth="size"
    CssClass="string"
    DataSource="string"
    DataSourceID="string"
    DisappearAfter="integer"
    DynamicBottomSeparatorImageUrl="uri"
    DynamicEnableDefaultPopOutImage="True|False"
    DynamicHorizontalOffset="integer"
    DynamicItemFormatString="string"
    DynamicPopOutImageTextFormatString="string"
    DynamicPopOutImageUrl="uri"
    DynamicTopSeparatorImageUrl="uri"
    DynamicVerticalOffset="integer"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
        Large|X-Large|XX-Large"
    Font-Strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    Height="size"
    ID="string"
    ItemWrap="True|False"
    MaximumDynamicDisplayLevels="integer"
    OnDataBinding="DataBinding event handler"
    OnDataBound="DataBound event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnMenuItemClick="MenuItemClick event handler"
    OnMenuItemDataBound="MenuItemDataBound event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    Orientation="Horizontal|Vertical"
    PathSeparator="string"
    runat="server"
    ScrollDownImageUrl="uri"
    ScrollDownText="string"
    ScrollUpImageUrl="uri"
    ScrollUpText="string"
    SkinID="string"
    SkipLinkText="string"
    StaticBottomSeparatorImageUrl="uri"
    StaticDisplayLevels="integer"
    StaticEnableDefaultPopOutImage="True|False"
    StaticItemFormatString="string"
    StaticPopOutImageTextFormatString="string"
    StaticPopOutImageUrl="uri"
    StaticSubMenuIndent="size"
    StaticTopSeparatorImageUrl="uri"
    Style="string"
    TabIndex="integer"
    Target="string"
    ToolTip="string"
    Visible="True|False"
    Width="size"
>
        <DataBindings>
                <asp:MenuItemBinding
                    DataMember="string"
                    Depth="integer"
                    Enabled="True|False"
                    EnabledField="string"
                    FormatString="string"
                    ImageUrl="uri"
                    ImageUrlField="string"
                    NavigateUrl="uri"
                    NavigateUrlField="string"
                    PopOutImageUrl="uri"
                    PopOutImageUrlField="string"
                    Selectable="True|False"
                    SelectableField="string"
                    SeparatorImageUrl="uri"
                    SeparatorImageUrlField="string"
                    Target="string"
                    TargetField="string"
                    Text="string"
                    TextField="string"
                    ToolTip="string"
                    ToolTipField="string"
                    Value="string"
                    ValueField="string"
                />
        </DataBindings>
        <DynamicHoverStyle />
        <DynamicItemTemplate>
            <!-- child controls -->
        </DynamicItemTemplate>
        <DynamicMenuItemStyle
            BackColor="color name|#dddddd"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
                Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CssClass="string"
            Font-Bold="True|False"
            Font-Italic="True|False"
            Font-Names="string"
            Font-Overline="True|False"
            Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
                Medium|Large|X-Large|XX-Large"
            Font-Strikeout="True|False"
            Font-Underline="True|False"
            ForeColor="color name|#dddddd"
            Height="size"
            HorizontalPadding="size"
            ItemSpacing="size"
            OnDisposed="Disposed event handler"
            VerticalPadding="size"
            Width="size"
        />
        <DynamicMenuStyle
            BackColor="color name|#dddddd"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
                Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CssClass="string"
            Font-Bold="True|False"
            Font-Italic="True|False"
            Font-Names="string"
            Font-Overline="True|False"
            Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
                Medium|Large|X-Large|XX-Large"
            Font-Strikeout="True|False"
            Font-Underline="True|False"
            ForeColor="color name|#dddddd"
            Height="size"
            HorizontalPadding="size"
            OnDisposed="Disposed event handler"
            VerticalPadding="size"
            Width="size"
        />
        <DynamicSelectedStyle
            BackColor="color name|#dddddd"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
                Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CssClass="string"
            Font-Bold="True|False"
            Font-Italic="True|False"
            Font-Names="string"
            Font-Overline="True|False"
            Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
                Medium|Large|X-Large|XX-Large"
            Font-Strikeout="True|False"
            Font-Underline="True|False"
            ForeColor="color name|#dddddd"
            Height="size"
            HorizontalPadding="size"
            ItemSpacing="size"
            OnDisposed="Disposed event handler"
            VerticalPadding="size"
            Width="size"
        />
        <Items />
        <LevelMenuItemStyles>
                <asp:MenuItemStyle
                    BackColor="color name|#dddddd"
                    BorderColor="color name|#dddddd"
                    BorderStyle="NotSet|None|Dotted|Dashed|Solid|
                        Double|Groove|Ridge|Inset|Outset"
                    BorderWidth="size"
                    CssClass="string"
                    Font-Bold="True|False"
                    Font-Italic="True|False"
                    Font-Names="string"
                    Font-Overline="True|False"
                    Font-Size="string|Smaller|Larger|XX-Small|
                        X-Small|Small|Medium|Large|X-Large|XX-Large"
                    Font-Strikeout="True|False"
                    Font-Underline="True|False"
                    ForeColor="color name|#dddddd"
                    Height="size"
                    HorizontalPadding="size"
                    ItemSpacing="size"
                    OnDisposed="Disposed event handler"
                    VerticalPadding="size"
                    Width="size"
                />
        </LevelMenuItemStyles>
        <LevelSelectedStyles>
                <asp:MenuItemStyle
                    BackColor="color name|#dddddd"
                    BorderColor="color name|#dddddd"
                    BorderStyle="NotSet|None|Dotted|Dashed|Solid|
                        Double|Groove|Ridge|Inset|Outset"
                    BorderWidth="size"
                    CssClass="string"
                    Font-Bold="True|False"
                    Font-Italic="True|False"
                    Font-Names="string"
                    Font-Overline="True|False"
                    Font-Size="string|Smaller|Larger|XX-Small|
                        X-Small|Small|Medium|Large|X-Large|XX-Large"
                    Font-Strikeout="True|False"
                    Font-Underline="True|False"
                    ForeColor="color name|#dddddd"
                    Height="size"
                    HorizontalPadding="size"
                    ItemSpacing="size"
                    OnDisposed="Disposed event handler"
                    VerticalPadding="size"
                    Width="size"
                />
        </LevelSelectedStyles>
        <LevelSubMenuStyles>
                <asp:SubMenuStyle
                    BackColor="color name|#dddddd"
                    BorderColor="color name|#dddddd"
                    BorderStyle="NotSet|None|Dotted|Dashed|Solid|
                        Double|Groove|Ridge|Inset|Outset"
                    BorderWidth="size"
                    CssClass="string"
                    Font-Bold="True|False"
                    Font-Italic="True|False"
                    Font-Names="string"
                    Font-Overline="True|False"
                    Font-Size="string|Smaller|Larger|XX-Small|
                        X-Small|Small|Medium|Large|X-Large|XX-Large"
                    Font-Strikeout="True|False"
                    Font-Underline="True|False"
                    ForeColor="color name|#dddddd"
                    Height="size"
                    HorizontalPadding="size"
                    OnDisposed="Disposed event handler"
                    VerticalPadding="size"
                    Width="size"
                />
        </LevelSubMenuStyles>
        <StaticHoverStyle />
        <StaticItemTemplate>
            <!-- child controls -->
        </StaticItemTemplate>
        <StaticMenuItemStyle
            BackColor="color name|#dddddd"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
                Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CssClass="string"
            Font-Bold="True|False"
            Font-Italic="True|False"
            Font-Names="string"
            Font-Overline="True|False"
            Font-Size="string|Smaller|Larger|XX-Small|
                X-Small|Small|Medium|Large|X-Large|XX-Large"
            Font-Strikeout="True|False"
            Font-Underline="True|False"
            ForeColor="color name|#dddddd"
            Height="size"
            HorizontalPadding="size"
            ItemSpacing="size"
            OnDisposed="Disposed event handler"
            VerticalPadding="size"
            Width="size"
        />
        <StaticMenuStyle
            BackColor="color name|#dddddd"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
                Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CssClass="string"
            Font-Bold="True|False"
            Font-Italic="True|False"
            Font-Names="string"
            Font-Overline="True|False"
            Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
                Medium|Large|X-Large|XX-Large"
            Font-Strikeout="True|False"
            Font-Underline="True|False"
            ForeColor="color name|#dddddd"
            Height="size"
            HorizontalPadding="size"
            OnDisposed="Disposed event handler"
            VerticalPadding="size"
            Width="size"
        />
        <StaticSelectedStyle
            BackColor="color name|#dddddd"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|
                Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CssClass="string"
            Font-Bold="True|False"
            Font-Italic="True|False"
            Font-Names="string"
            Font-Overline="True|False"
            Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|
                Medium|Large|X-Large|XX-Large"
            Font-Strikeout="True|False"
            Font-Underline="True|False"
            ForeColor="color name|#dddddd"
            Height="size"
            HorizontalPadding="size"
            ItemSpacing="size"
            OnDisposed="Disposed event handler"
            VerticalPadding="size"
            Width="size"
        />
</asp:Menu>
TopicLocation
How to: Programmatically Enumerate Site-Map NodesBuilding ASP .NET Web Applications
How to: Configure Multiple Site Maps and Site-Map ProvidersBuilding ASP .NET Web Applications
How to: Filter the Nodes Retrieved by SiteMapDataSource Web Server ControlsBuilding ASP .NET Web Applications
How to: Customize the Appearance of SiteMapPath Web Server ControlsBuilding ASP .NET Web Applications
How to: Display Site-Map Data in Non-Hierarchical Web Server ControlsBuilding ASP .NET Web Applications
How to: Add Simple Site NavigationBuilding ASP .NET Web Applications
How to: Implement ASP.NET Site-Map ProvidersBuilding ASP .NET Web Applications
How to: Programmatically Enumerate Site-Map NodesBuilding ASP .NET Web Applications
How to: Configure Multiple Site Maps and Site-Map ProvidersBuilding ASP .NET Web Applications
How to: Filter the Nodes Retrieved by SiteMapDataSource Web Server ControlsBuilding ASP .NET Web Applications
How to: Customize the Appearance of SiteMapPath Web Server ControlsBuilding ASP .NET Web Applications
How to: Display Site-Map Data in Non-Hierarchical Web Server ControlsBuilding ASP .NET Web Applications
How to: Add Simple Site NavigationBuilding ASP .NET Web Applications
How to: Implement ASP.NET Site-Map ProvidersBuilding ASP .NET Web Applications
Walkthrough: Adding Site Navigation to a Web SiteBuilding ASP .NET Web Applications in Visual Studio
Walkthrough: Displaying a Menu on Web PagesBuilding ASP .NET Web Applications in Visual Studio
Walkthrough: Controlling ASP.NET Menus ProgrammaticallyBuilding ASP .NET Web Applications in Visual Studio

A Visual Studio Web site project with source code is available to accompany this topic: Download.

The following code example demonstrates how to create a Menu control with static menu items using declarative syntax.

No code example is currently available or this language may not be supported.

The following code example demonstrates how to bind the Menu control to a SiteMapDataSource control. For this example to work correctly, you must copy the sample site map data below to a file named Web.sitemap.

No code example is currently available or this language may not be supported.

The following is sample site map data for the previous example.

<siteMap>
  <siteMapNode url="~\Home.aspx" 
    title="Home"
    description="Home">
    <siteMapNode url="~\Music.aspx"
      title="Music"
      description="Music">
      <siteMapNode url="~\Classical.aspx" 
        title="Classical"
        description="Classical"/>
      <siteMapNode url="~\Rock.aspx"
        title="Rock"
        description="Rock"/>
      <siteMapNode url="~\Jazz.aspx"
        title="Jazz"
        description="Jazz"/>
    </siteMapNode>
    <siteMapNode url="~\Movies.aspx"
      title="Movies"
      description="Movies">
      <siteMapNode url="~\Action.aspx"
        title="Action"
        description="Action"/>
      <siteMapNode url="~\Drama.aspx"
        title="Drama"
        description="Drama"/>
      <siteMapNode url="~\Musical.aspx"
        title="Musical"
        description="Musical"/>
    </siteMapNode>
  </siteMapNode>
</siteMap>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft