Suggérer une traduction
 
Suggestions d'autres utilisateurs :

progress indicator
Aucune autre suggestion.
Cliquez pour évaluer et commenter
MSDN
MSDN Library
Développement .NET
.NET Framework 4
Espaces de noms System.Web
System.Web.UI.WebControls
Menu, classe
Réduire tout/Développer tout Réduire tout
Affichage du contenu :  côte à côteAffichage du contenu : côte à côte
.NET Framework Class Library
Menu Class

Displays a menu in an ASP.NET Web page.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
Visual Basic
<ControlValuePropertyAttribute("SelectedValue")> _
Public Class Menu _
    Inherits HierarchicalDataBoundControl _
    Implements IPostBackEventHandler, INamingContainer
C#
[ControlValuePropertyAttribute("SelectedValue")]
public class Menu : HierarchicalDataBoundControl, IPostBackEventHandler, INamingContainer
Visual C++
[ControlValuePropertyAttribute(L"SelectedValue")]
public ref class Menu : public HierarchicalDataBoundControl, 
    IPostBackEventHandler, INamingContainer
F#
[<ControlValuePropertyAttribute("SelectedValue")>]
type Menu =  
    class
        inherit HierarchicalDataBoundControl
        interface IPostBackEventHandler
        interface INamingContainer
    end
ASP.NET
<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 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 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.)
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 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 nullNothingnullptra null reference (Nothing in Visual Basic). (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 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 a hash function for a particular type. (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 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<(Of <(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<(Of <(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
Comment : afficher des données sitemap dans des contrôles serveur Web non hiérarchiquesGénération d'applications Web ASP.NET
Comment : afficher des données sitemap dans des contrôles serveur Web non hiérarchiquesGénération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter la navigation de site simpleGénération d'applications Web ASP.NET
Comment : ajouter la navigation de site simpleGénération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter la navigation de site simpledv_vwdcon
Comment : configurer plusieurs plans de sites et fournisseurs sitemapGénération d'applications Web ASP.NET
Comment : configurer plusieurs plans de sites et fournisseurs sitemapGénération d'applications Web ASP.NET dans Visual Studio
Comment : énumérer par programme des nœuds sitemapGénération d'applications Web ASP.NET
Comment : énumérer par programme des nœuds sitemapGénération d'applications Web ASP.NET dans Visual Studio
Comment : filtrer les nœuds récupérés par les contrôles serveur Web SiteMapDataSourceGénération d'applications Web ASP.NET
Comment : filtrer les nœuds récupérés par les contrôles serveur Web SiteMapDataSourceGénération d'applications Web ASP.NET dans Visual Studio
Comment : implémenter des fournisseurs sitemap ASP.NETGénération d'applications Web ASP.NET
Comment : implémenter des fournisseurs sitemap ASP.NETGénération d'applications Web ASP.NET dans Visual Studio
Comment : personnaliser l'apparence des contrôles serveur Web SiteMapPathGénération d'applications Web ASP.NET
Comment : personnaliser l'apparence des contrôles serveur Web SiteMapPathGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : affichage d'un menu sur des pages WebGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : affichage d'un menu sur des pages WebGénération d'applications à l'aide de Visual Web Developer
Procédure pas à pas : ajout de la navigation de site à un site WebGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : ajout de la navigation de site à un site WebGénération d'applications à l'aide de Visual Web Developer
Procédure pas à pas : contrôle des menus ASP.NET par programmeGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : contrôle des menus ASP.NET par programmeGénération d'applications Web ASP.NET dans 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.

Visual Basic

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu Declarative Example</title>
</head>

  <body>
    <form id="form1" runat="server">

      <h3>Menu Declarative Example</h3>

      <!-- Use declarative syntax to create the   -->
      <!-- menu structure. Submenu items are      -->
      <!-- created by nesting them in parent menu -->
      <!-- items.                                 -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        font-names="Arial" 
        target="_blank"  
        runat="server">

        <staticmenuitemstyle backcolor="LightSteelBlue"
          forecolor="Black"/>
        <statichoverstyle backcolor="LightSkyBlue"/>
        <dynamicmenuitemstyle backcolor="Black"
          forecolor="Silver"/>
        <dynamichoverstyle backcolor="LightSkyBlue"
          forecolor="Black"/>

        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Home"
            tooltip="Home">
            <asp:menuitem navigateurl="Music.aspx"
              text="Music"
              tooltip="Music">
              <asp:menuitem navigateurl="Classical.aspx" 
                text="Classical"
                tooltip="Classical"/>
              <asp:menuitem navigateurl="Rock.aspx"
                text="Rock"
                tooltip="Rock"/>
              <asp:menuitem navigateurl="Jazz.aspx"
                text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem navigateurl="Movies.aspx"
              text="Movies"
              tooltip="Movies">
              <asp:menuitem navigateurl="Action.aspx"
                text="Action"
                tooltip="Action"/>
              <asp:menuitem navigateurl="Drama.aspx"
                text="Drama"
                tooltip="Drama"/>
              <asp:menuitem navigateurl="Musical.aspx"
                text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>

      </asp:menu>

    </form>
  </body>
</html>

C#

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu Declarative Example</title>
</head>

  <body>
    <form id="form1" runat="server">

      <h3>Menu Declarative Example</h3>

      <!-- Use declarative syntax to create the   -->
      <!-- menu structure. Submenu items are      -->
      <!-- created by nesting them in parent menu -->
      <!-- items.                                 -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        font-names="Arial" 
        target="_blank"  
        runat="server">

        <staticmenuitemstyle backcolor="LightSteelBlue"
          forecolor="Black"/>
        <statichoverstyle backcolor="LightSkyBlue"/>
        <dynamicmenuitemstyle backcolor="Black"
          forecolor="Silver"/>
        <dynamichoverstyle backcolor="LightSkyBlue"
          forecolor="Black"/>

        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Home"
            tooltip="Home">
            <asp:menuitem navigateurl="Music.aspx"
              text="Music"
              tooltip="Music">
              <asp:menuitem navigateurl="Classical.aspx" 
                text="Classical"
                tooltip="Classical"/>
              <asp:menuitem navigateurl="Rock.aspx"
                text="Rock"
                tooltip="Rock"/>
              <asp:menuitem navigateurl="Jazz.aspx"
                text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem navigateurl="Movies.aspx"
              text="Movies"
              tooltip="Movies">
              <asp:menuitem navigateurl="Action.aspx"
                text="Action"
                tooltip="Action"/>
              <asp:menuitem navigateurl="Drama.aspx"
                text="Drama"
                tooltip="Drama"/>
              <asp:menuitem navigateurl="Musical.aspx"
                text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>

      </asp:menu>

    </form>
  </body>
</html>

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.

Visual Basic

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu DataBinding Example</title>
</head>

  <body>
    <form id="form1" runat="server">

      <h3>Menu DataBinding Example</h3>

      <!-- Bind the Menu control to a SiteMapDataSource control.  -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        font-names="Arial" 
        target="_blank"
        datasourceid="MenuSource"   
        runat="server">

        <staticmenuitemstyle backcolor="LightSteelBlue"
          forecolor="Black"/>
        <statichoverstyle backcolor="LightSkyBlue"/>
        <dynamicmenuitemstyle backcolor="Black"
          forecolor="Silver"/>
        <dynamichoverstyle backcolor="LightSkyBlue"
          forecolor="Black"/>

      </asp:menu>

      <asp:SiteMapDataSource id="MenuSource"
        runat="server"/>        

    </form>
  </body>
</html>

C#

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu DataBinding Example</title>
</head>

  <body>
    <form id="form1" runat="server">

      <h3>Menu DataBinding Example</h3>

      <!-- Bind the Menu control to a SiteMapDataSource control.  -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        font-names="Arial" 
        target="_blank"
        datasourceid="MenuSource"   
        runat="server">

        <staticmenuitemstyle backcolor="LightSteelBlue"
          forecolor="Black"/>
        <statichoverstyle backcolor="LightSkyBlue"/>
        <dynamicmenuitemstyle backcolor="Black"
          forecolor="Silver"/>
        <dynamichoverstyle backcolor="LightSkyBlue"
          forecolor="Black"/>

      </asp:menu>

      <asp:SiteMapDataSource id="MenuSource"
        runat="server"/>        

    </form>
  </body>
</html>

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, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

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.
Bibliothèque de classes .NET Framework
Menu, classe

Affiche un menu dans une page Web ASP.NET.

Espace de noms :  System.Web.UI.WebControls
Assembly :  System.Web (dans System.Web.dll)
Visual Basic
<ControlValuePropertyAttribute("SelectedValue")> _
Public Class Menu _
    Inherits HierarchicalDataBoundControl _
    Implements IPostBackEventHandler, INamingContainer
C#
[ControlValuePropertyAttribute("SelectedValue")]
public class Menu : HierarchicalDataBoundControl, IPostBackEventHandler, INamingContainer
VisualC++
[ControlValuePropertyAttribute(L"SelectedValue")]
public ref class Menu : public HierarchicalDataBoundControl, 
    IPostBackEventHandler, INamingContainer
F#
[<ControlValuePropertyAttribute("SelectedValue")>]
type Menu =  
    class
        inherit HierarchicalDataBoundControl
        interface IPostBackEventHandler
        interface INamingContainer
    end
ASP.NET
<asp:Menu />

Le type Menu expose les membres suivants.

  NomDescription
Méthode publiqueMenuInitialise une nouvelle instance de la classe Menu.
Début
  NomDescription
Propriété publiqueAccessKeyObtient ou définit la touche d'accès rapide qui vous permet de naviguer rapidement vers le contrôle serveur Web. (Hérité de WebControl.)
Propriété protégéeAdapterObtient l'adaptateur spécifique au navigateur pour le contrôle. (Hérité de Control.)
Propriété publiqueAppRelativeTemplateSourceDirectoryObtient ou définit le répertoire virtuel relatif à l'application de l'objet Page ou UserControl qui contient ce contrôle. (Hérité de Control.)
Propriété publiqueAttributesObtient la collection d'attributs arbitraires (pour le rendu uniquement) qui ne correspondent pas à des propriétés du contrôle. (Hérité de WebControl.)
Propriété publiqueBackColorObtient ou définit la couleur d'arrière-plan du contrôle serveur Web. (Hérité de WebControl.)
Propriété publiqueBindingContainerInfrastructure. Obtient le contrôle qui contient la liaison de données de ce contrôle. (Hérité de Control.)
Propriété publiqueBorderColorObtient ou définit la couleur de bordure du contrôle Web. (Hérité de WebControl.)
Propriété publiqueBorderStyleObtient ou définit le style de bordure du contrôle serveur Web. (Hérité de WebControl.)
Propriété publiqueBorderWidthObtient ou définit la largeur de bordure du contrôle serveur Web. (Hérité de WebControl.)
Propriété protégéeChildControlsCreatedObtient une valeur qui indique si des contrôles enfants du contrôle serveur ont été créés. (Hérité de Control.)
Propriété publiqueClientIDObtient l'ID de contrôle pour le balisage HTML généré par ASP.NET. (Hérité de Control.)
Propriété publiqueClientIDModeObtient ou définit l'algorithme utilisé pour générer la valeur de la propriété ClientID. (Hérité de Control.)
Propriété protégéeClientIDSeparatorObtient une valeur de caractère représentant le caractère de séparation utilisé dans la propriété ClientID. (Hérité de Control.)
Propriété protégéeContextObtient l'objet HttpContext associé au contrôle serveur pour la demande Web en cours. (Hérité de Control.)
Propriété publiqueControlsObtient un ControlCollection qui contient les contrôles enfants du contrôle Menu. (Substitue Control..::.Controls.)
Propriété publiqueControlStyleObtient le style d'un contrôle serveur Web. Cette propriété est principalement utilisée par des développeurs de contrôles. (Hérité de WebControl.)
Propriété publiqueControlStyleCreatedObtient une valeur indiquant si un objet Style a été créé pour la propriété ControlStyle. Cette propriété est principalement utilisée par des développeurs de contrôles. (Hérité de WebControl.)
Propriété publiqueCssClassObtient ou définit la classe de feuille de style en cascade (CSS, Cascading Style Sheet) rendue par le contrôle serveur Web sur le client. (Hérité de WebControl.)
Propriété publiqueDataBindingsObtient une collection d'objets MenuItemBinding qui définissent la relation entre un élément de données et l'élément de menu auquel il est lié.
Propriété publiqueDataItemContainerObtient une référence au conteneur d'attribution de noms si celui-ci implémente IDataItemContainer. (Hérité de Control.)
Propriété publiqueDataKeysContainerObtient une référence au conteneur d'attribution de noms si celui-ci implémente IDataKeysControl. (Hérité de Control.)
Propriété publiqueDataSourceObtient ou définit l'objet duquel le contrôle lié aux données récupère sa liste d'éléments de données. (Hérité de BaseDataBoundControl.)
Propriété publiqueDataSourceIDObtient ou définit l'ID du contrôle duquel le contrôle lié aux données récupère sa liste d'éléments de données. (Hérité de HierarchicalDataBoundControl.)
Propriété protégéeDesignModeObtient une valeur indiquant si un contrôle est utilisé sur une aire de conception. (Hérité de Control.)
Propriété publiqueDisappearAfterObtient ou définit la durée d'affichage d'un menu dynamique lorsque le pointeur de la souris n'est plus positionné sur le menu.
Propriété publiqueDynamicBottomSeparatorImageUrlObtient ou définit l'URL à une image à afficher en bas de chaque élément de menu dynamique pour le séparer des autres éléments de menu.
Propriété publiqueDynamicEnableDefaultPopOutImageObtient ou définit une valeur indiquant si l'image intégrée qui indique qu'un élément de menu dynamique a un sous-menu est affichée.
Propriété publiqueDynamicHorizontalOffsetObtient ou définit le nombre de pixels utilisés pour déplacer horizontalement un menu dynamique par rapport à son élément de menu parent.
Propriété publiqueDynamicHoverStyleObtient une référence à l'objet Style qui vous permet de définir l'apparence d'un élément de menu dynamique lorsque le pointeur de la souris est positionné sur lui.
Propriété publiqueDynamicItemFormatStringObtient ou définit le texte supplémentaire affiché avec tous les éléments de menu affichés de manière dynamique.
Propriété publiqueDynamicItemTemplateObtient ou définit le modèle qui contient le contenu personnalisé à rendre pour un menu dynamique.
Propriété publiqueDynamicMenuItemStyleObtient une référence à l'objet MenuItemStyle vous permettant de définir l'apparence des éléments de menu d'un menu dynamique.
Propriété publiqueDynamicMenuStyleObtient une référence à l'objet MenuItemStyle vous permettant de définir l'apparence d'un menu dynamique.
Propriété publiqueDynamicPopOutImageTextFormatStringObtient ou définit le texte de remplacement de l'image utilisée pour indiquer qu'un élément de menu dynamique a un sous-menu.
Propriété publiqueDynamicPopOutImageUrlObtient ou définit l'URL vers une image personnalisée qui est affichée dans un élément de menu dynamique lorsque ce dernier a un sous-menu.
Propriété publiqueDynamicSelectedStyleObtient une référence à l'objet MenuItemStyle vous permettant de définir l'apparence de l'élément de menu dynamique sélectionné par l'utilisateur.
Propriété publiqueDynamicTopSeparatorImageUrlObtient ou définit l'URL à une image à afficher en haut de chaque élément de menu dynamique pour le séparer des autres éléments de menu.
Propriété publiqueDynamicVerticalOffsetObtient ou définit le nombre de pixels à utiliser pour déplacer verticalement un menu dynamique par rapport à son élément de menu parent.
Propriété publiqueEnabledObtient ou définit une valeur indiquant si le contrôle serveur Web est activé. (Hérité de WebControl.)
Propriété publiqueEnableThemingObtient ou définit une valeur indiquant si les thèmes s'appliquent à ce contrôle. (Hérité de WebControl.)
Propriété publiqueEnableViewStateObtient ou définit une valeur indiquant si le contrôle serveur rend persistant son état d'affichage, ainsi que celui de tous les contrôles enfants qu'il contient, sur le client à l'origine de la demande. (Hérité de Control.)
Propriété protégéeEventsObtient la liste des délégués de gestionnaires d'événements pour le contrôle. Cette propriété est en lecture seule. (Hérité de Control.)
Propriété publiqueFontObtient les propriétés de police associées au contrôle serveur Web. (Hérité de WebControl.)
Propriété publiqueForeColorObtient ou définit la couleur de premier plan (généralement la couleur du texte) du contrôle serveur Web. (Hérité de WebControl.)
Propriété publiqueHasAttributesObtient une valeur indiquant si le contrôle a des attributs définis. (Hérité de WebControl.)
Propriété protégéeHasChildViewStateObtient une valeur indiquant si les contrôles enfants du contrôle serveur en cours possèdent des paramètres d'état d'affichage enregistrés. (Hérité de Control.)
Propriété publiqueHeightObtient ou définit la hauteur du contrôle serveur Web. (Hérité de WebControl.)
Propriété publiqueIDObtient ou définit l'ID programmatique assigné au contrôle serveur. (Hérité de Control.)
Propriété protégéeIdSeparatorInfrastructure. Obtient le caractère utilisé pour séparer des identificateurs de contrôle. (Hérité de Control.)
Propriété publiqueIncludeStyleBlockObtient ou définit une valeur qui indique si ASP.NET doit restituer un bloc de définitions de feuille de style en cascade (CSS) pour les styles utilisés dans le menu.
Propriété protégéeInitializedObtient une valeur indiquant si le contrôle lié aux données a été initialisé. (Hérité de BaseDataBoundControl.)
Propriété protégéeIsBoundUsingDataSourceIDObtient une valeur indiquant si la propriété DataSourceID est définie. (Hérité de BaseDataBoundControl.)
Propriété protégéeIsChildControlStateClearedObtient une valeur indiquant si les contrôles contenus dans ce contrôle utilisent l'état du contrôle. (Hérité de Control.)
Propriété protégéeIsEnabledObtient une valeur indiquant si le contrôle est activé. (Hérité de WebControl.)
Propriété protégéeIsTrackingViewStateObtient une valeur qui indique si le contrôle serveur enregistre les modifications apportées à son état d'affichage. (Hérité de Control.)
Propriété protégéeIsViewStateEnabledObtient une valeur indiquant si l'état d'affichage est activé pour ce contrôle. (Hérité de Control.)
Propriété publiqueItemsObtient un objet MenuItemCollection qui contient tous les éléments de menu du contrôle Menu.
Propriété publiqueItemWrapObtient ou définit une valeur indiquant si le texte des éléments de menu doit être automatiquement renvoyé à la ligne.
Propriété publiqueLevelMenuItemStylesObtient un objet MenuItemStyleCollection qui contient les paramètres de style appliqués aux éléments de menu en fonction de leur niveau dans un contrôle Menu.
Propriété publiqueLevelSelectedStylesObtient un objet MenuItemStyleCollection qui contient les paramètres de style appliqués à l'élément de menu sélectionné en fonction de son niveau dans un contrôle Menu.
Propriété publiqueLevelSubMenuStylesObtient un objet MenuItemStyleCollection qui contient les paramètres de style appliqués aux éléments de sous-menu du menu statique en fonction de leur niveau dans un contrôle Menu.
Propriété protégéeLoadViewStateByIDObtient une valeur indiquant si le contrôle participe au chargement de son état d'affichage par ID et non par index. (Hérité de Control.)
Propriété publiqueMaximumDynamicDisplayLevelsObtient ou définit le nombre de niveaux de menu à rendre pour un menu dynamique.
Propriété publiqueNamingContainerObtient une référence au conteneur d'attribution de noms du contrôle serveur, qui crée un espace de noms unique pour différencier les contrôles serveur dont la propriété Control..::.ID possède la même valeur. (Hérité de Control.)
Propriété publiqueOrientationObtient ou définit le sens dans lequel rendre le contrôle Menu.
Propriété publiquePageObtient une référence à l'instance de Page qui contient le contrôle serveur. (Hérité de Control.)
Propriété publiqueParentObtient une référence au contrôle parent du contrôle serveur dans la hiérarchie des contrôles de la page. (Hérité de Control.)
Propriété publiquePathSeparatorObtient ou définit le caractère utilisé pour délimiter le chemin d'un élément de menu dans un contrôle Menu.
Propriété publiqueRenderingCompatibilityObtient une valeur qui spécifie la version ASP.NET avec laquelle le HTML restitué sera compatible. (Hérité de Control.)
Propriété publiqueRenderingModeObtient ou définit une valeur qui spécifie si le contrôle Menu restitue des éléments table HTML et des styles intralignes, ou des éléments listitem et des styles CSS.
Propriété protégéeRequiresDataBindingObtient ou définit une valeur indiquant si la méthode DataBind doit être appelée. (Hérité de BaseDataBoundControl.)
Propriété publiqueScrollDownImageUrlObtient ou définit l'URL vers une image affichée dans un menu dynamique pour indiquer que l'utilisateur peut faire défiler vers le bas pour afficher des éléments de menu supplémentaires.
Propriété publiqueScrollDownTextObtient ou définit le texte de remplacement de l'image spécifiée dans la propriété ScrollDownImageUrl.
Propriété publiqueScrollUpImageUrlObtient ou définit l'URL vers une image affichée dans un menu dynamique pour indiquer que l'utilisateur peut faire défiler vers le haut pour afficher des éléments de menu supplémentaires.
Propriété publiqueScrollUpTextObtient ou définit le texte de remplacement de l'image spécifiée dans la propriété ScrollUpImageUrl.
Propriété publiqueSelectedItemObtient l'élément de menu sélectionné.
Propriété publiqueSelectedValueObtient la valeur de l'élément de menu sélectionné.
Propriété publiqueSiteObtient des informations sur le conteneur qui héberge le contrôle en cours lorsqu'il est rendu sur une aire de conception. (Hérité de Control.)
Propriété publiqueSkinIDObtient ou définit l'apparence à appliquer au contrôle. (Hérité de WebControl.)
Propriété publiqueSkipLinkTextObtient ou définit le texte de remplacement d'une lecture d'image masquée par les lecteurs d'écran pour offrir la possibilité d'ignorer la liste de liens.
Propriété publiqueStaticBottomSeparatorImageUrlObtient ou définit l'URL vers une image affichée comme séparateur en bas de chaque élément de menu statique.
Propriété publiqueStaticDisplayLevelsObtient ou définit le nombre de niveaux de menu à afficher dans un menu statique.
Propriété publiqueStaticEnableDefaultPopOutImageObtient ou définit une valeur indiquant si l'image intégrée s'affiche pour indiquer qu'un élément de menu statique a un sous-menu.
Propriété publiqueStaticHoverStyleObtient une référence à l'objet Style qui vous permet de définir l'apparence d'un élément de menu statique lorsque le pointeur de la souris est positionné sur lui.
Propriété publiqueStaticItemFormatStringObtient ou définit le texte supplémentaire affiché avec tous les éléments de menu affichés de manière statique.
Propriété publiqueStaticItemTemplateObtient ou définit le modèle qui contient le contenu personnalisé à rendre pour un menu statique.
Propriété publiqueStaticMenuItemStyleObtient une référence à l'objet MenuItemStyle vous permettant de définir l'apparence des éléments de menu d'un menu statique.
Propriété publiqueStaticMenuStyleObtient une référence à l'objet MenuItemStyle vous permettant de définir l'apparence d'un menu statique.
Propriété publiqueStaticPopOutImageTextFormatStringObtient ou définit le texte de remplacement de l'image contextuelle utilisée pour indiquer qu'un élément de menu statique a un sous-menu.
Propriété publiqueStaticPopOutImageUrlObtient ou définit l'URL vers une image affichée pour indiquer qu'un élément de menu statique a un sous-menu.
Propriété publiqueStaticSelectedStyleObtient une référence à l'objet MenuItemStyle vous permettant de définir l'apparence de l'élément de menu sélectionné par l'utilisateur dans un menu statique.
Propriété publiqueStaticSubMenuIndentObtient ou définit la quantité d'espace, en pixels, pour mettre en retrait les sous-menus d'un menu statique.
Propriété publiqueStaticTopSeparatorImageUrlObtient ou définit l'URL vers une image affichée comme séparateur en haut de chaque élément de menu statique.
Propriété publiqueStyleObtient une collection d'attributs de texte qui sont rendus en tant qu'attribut de style sur la balise extérieure d'un contrôle serveur Web. (Hérité de WebControl.)
Propriété publiqueSupportsDisabledAttributeObtient une valeur qui indique si le contrôle doit affecter à l'attribut disabled de l'élément HTML rendu la valeur "disabled" lorsque la propriété IsEnabled du contrôle a la valeur false. (Hérité de BaseDataBoundControl.)
Propriété publiqueTabIndexObtient ou définit l'index de tabulation du contrôle serveur Web. (Hérité de WebControl.)
Propriété protégéeTagKeyObtient la valeur HtmlTextWriterTag qui correspond à un contrôle Menu. Cette propriété est principalement utilisée par des développeurs de contrôles. (Substitue WebControl..::.TagKey.)
Propriété protégéeTagNameObtient le nom de la balise du contrôle. Cette propriété est principalement utilisée par des développeurs de contrôles. (Hérité de WebControl.)
Propriété publiqueTargetObtient ou définit la fenêtre ou frame cible dans lequel afficher le contenu de la page Web associé à un élément de menu.
Propriété publiqueTemplateControlObtient ou définit une référence au modèle qui contient ce contrôle. (Hérité de Control.)
Propriété publiqueTemplateSourceDirectoryObtient le répertoire virtuel du Page ou du UserControl qui contient le contrôle serveur en cours. (Hérité de Control.)
Propriété publiqueToolTipObtient ou définit le texte affiché quand le pointeur de la souris est positionné sur le contrôle serveur Web. (Hérité de WebControl.)
Propriété publiqueUniqueIDObtient l'identificateur unique qualifié sur le plan hiérarchique du contrôle serveur. (Hérité de Control.)
Propriété protégéeViewStateObtient un dictionnaire d'informations d'état qui vous permet d'enregistrer et de restaurer l'état d'affichage d'un contrôle serveur entre plusieurs demandes de la même page. (Hérité de Control.)
Propriété protégéeViewStateIgnoresCaseObtient une valeur qui indique si l'objet StateBag respecte la casse. (Hérité de Control.)
Propriété publiqueViewStateModeObtient ou définit le mode d'état d'affichage de ce contrôle. (Hérité de Control.)
Propriété publiqueVisibleObtient ou définit une valeur qui indique si un contrôle serveur est rendu sous la forme d'une interface utilisateur sur la page. (Hérité de Control.)
Propriété publiqueWidthObtient ou définit la largeur du contrôle serveur Web. (Hérité de WebControl.)
Début
  NomDescription
Méthode protégéeAddAttributesToRenderAjoute des attributs et des styles HTML qui doivent être rendus à l'objet HtmlTextWriter spécifié. (Substitue WebControl..::.AddAttributesToRender(HtmlTextWriter).)
Méthode protégéeAddedControlAppelée après l'ajout d'un contrôle enfant à la collection Controls de l'objet Control. (Hérité de Control.)
Méthode protégéeAddParsedSubObjectAvertit le contrôle serveur qu'un élément XML ou HTML a été analysé et l'ajoute à l'objet ControlCollection du contrôle serveur. (Hérité de Control.)
Méthode publiqueApplyStyleCopie tous les éléments non vides du style spécifié vers le contrôle Web, en remplaçant les éléments de style existants du contrôle. Cette méthode est principalement utilisée par des développeurs de contrôles. (Hérité de WebControl.)
Méthode publiqueApplyStyleSheetSkinApplique les propriétés de style définies dans la feuille de style de la page au contrôle. (Hérité de Control.)
Méthode protégéeBuildProfileTreeInfrastructure. Collecte des informations sur le contrôle serveur et les livre à la propriété Trace à afficher lorsque le traçage est activé pour la page. (Hérité de Control.)
Méthode protégéeClearCachedClientIDInfrastructure. Affecte à la valeur ClientID mise en cache la valeur nullNothingnullptrune référence null (Nothing en Visual Basic). (Hérité de Control.)
Méthode protégéeClearChildControlStateSupprime les informations sur l'état du contrôle des contrôles enfants du contrôle serveur. (Hérité de Control.)
Méthode protégéeClearChildStateSupprime les informations sur l'état d'affichage et sur l'état du contrôle de tous les contrôles enfants du contrôle serveur. (Hérité de Control.)
Méthode protégéeClearChildViewStateSupprime les informations d'état d'affichage de tous les contrôles enfants du contrôle serveur. (Hérité de Control.)
Méthode protégéeClearEffectiveClientIDModeInfrastructure. Affecte la valeur Inherit à la propriété ClientIDMode de l'instance de contrôle actuelle et de tous contrôles enfants. (Hérité de Control.)
Méthode protégéeConfirmInitStateDéfinit l'état initialisé du contrôle lié aux données. (Hérité de BaseDataBoundControl.)
Méthode publiqueCopyBaseAttributesCopie les propriétés non encapsulées par l'objet Style du contrôle serveur Web spécifié vers le contrôle serveur Web à partir duquel cette méthode est appelée. Cette méthode est principalement utilisée par des développeurs de contrôles. (Hérité de WebControl.)
Méthode protégéeCreateChildControlsCrée les contrôles enfants d'un contrôle Menu. (Substitue Control..::.CreateChildControls()()().)
Méthode protégéeCreateControlCollectionCrée un nouvel objet ControlCollection pour contenir les contrôles enfants (littéraux et serveur) du contrôle serveur. (Hérité de Control.)
Méthode protégéeCreateControlStyleCrée l'objet de style qui est utilisé de manière interne par la classe WebControl pour implémenter toutes les propriétés associées au style. Cette méthode est principalement utilisée par des développeurs de contrôles. (Hérité de WebControl.)
Méthode publiqueDataBind()()()Lie la source de données au contrôle Menu. Cette méthode ne peut pas être héritée. (Substitue BaseDataBoundControl..::.DataBind()()().)
Méthode protégéeDataBind(Boolean)Lie une source de données au contrôle serveur appelé et tous ses contrôles enfants avec une option pour déclencher l'événement DataBinding. (Hérité de Control.)
Méthode protégéeDataBindChildrenLie une source de données aux contrôles enfants du contrôle serveur. (Hérité de Control.)
Méthode publiqueDisposePermet à un contrôle serveur d'effectuer le nettoyage final avant qu'il soit libéré de la mémoire. (Hérité de Control.)
Méthode protégéeEnsureChildControlsDétermine si le contrôle serveur contient des contrôles enfants. S'il ne contient pas de contrôles enfants, il en crée. (Hérité de Control.)
Méthode protégéeEnsureDataBoundVérifie que le contrôle de menu requiert la liaison de données et qu'un contrôle de source de données valide est spécifié avant d'appeler la méthode DataBind. (Substitue BaseDataBoundControl..::.EnsureDataBound()()().)
Méthode protégéeEnsureIDCrée un identificateur pour les contrôles auxquels aucun identificateur n'est assigné. (Hérité de Control.)
Méthode publiqueEquals(Object)Détermine si l'Object spécifié est égal à l'Object en cours. (Hérité de Object.)
Méthode protégéeFinalizeAutorise un objet à tenter de libérer des ressources et d'exécuter d'autres opérations de netto***ge avant qu'il ne soit récupéré par l'opération garbage collection. (Hérité de Object.)
Méthode publiqueFindControl(String)Recherche un contrôle serveur possédant le paramètre id spécifié dans le conteneur d'attribution de noms actuel. (Hérité de Control.)
Méthode protégéeFindControl(String, Int32)Infrastructure. Recherche le conteneur d'attribution de noms actuel d'un contrôle serveur avec l'id spécifié et un entier, spécifié dans le paramètre pathOffset, qui facilite la recherche. Vous ne devez pas substituer cette version de la méthode FindControl. (Hérité de Control.)
Méthode publiqueFindItemRécupère l'élément de menu au chemin de valeur spécifié.
Méthode publiqueFocusAffecte le focus d'entrée à un contrôle. (Hérité de Control.)
Méthode protégéeGetDataRécupère un objet HierarchicalDataSourceView que le contrôle lié aux données utilise pour exécuter des opérations de données. (Hérité de HierarchicalDataBoundControl.)
Méthode protégéeGetDataSourceRécupère le IHierarchicalDataSource auquel le contrôle lié aux données est associé, le cas échéant. (Hérité de HierarchicalDataBoundControl.)
Méthode protégéeGetDesignModeStateRécupère l'état au moment du design du contrôle Menu. (Substitue Control..::.GetDesignModeState()()().)
Méthode publiqueGetHashCodeSert de fonction de hachage pour un type particulier. (Hérité de Object.)
Méthode publiqueGetRouteUrl(Object)Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire. (Hérité de Control.)
Méthode publiqueGetRouteUrl(RouteValueDictionary)Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire. (Hérité de Control.)
Méthode publiqueGetRouteUrl(String, Object)Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire et à un nom d'itinéraire. (Hérité de Control.)
Méthode publiqueGetRouteUrl(String, RouteValueDictionary)Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire et à un nom d'itinéraire. (Hérité de Control.)
Méthode publiqueGetTypeObtient le Type de l'instance actuelle. (Hérité de Object.)
Méthode publiqueGetUniqueIDRelativeToRetourne la partie préfixée de la propriété UniqueID du contrôle spécifié. (Hérité de Control.)
Méthode publiqueHasControlsDétermine si le contrôle serveur contient des contrôles enfants. (Hérité de Control.)
Méthode protégéeHasEventsRetourne une valeur indiquant si des événements sont inscrits pour le contrôle ou des contrôles enfants. (Hérité de Control.)
Méthode protégéeIsLiteralContentInfrastructure. Détermine si le contrôle serveur ne détient qu'un contenu littéral. (Hérité de Control.)
Méthode protégéeLoadControlStateCharge l'état des propriétés du contrôle Menu qui doivent être persistants. (Substitue Control..::.LoadControlState(Object).)
Méthode protégéeLoadViewStateCharge l'état d'affichage enregistré précédemment du contrôle Menu. (Substitue WebControl..::.LoadViewState(Object).)
Méthode protégéeMapPathSecureRécupère le chemin d'accès physique auquel un chemin d'accès virtuel, absolu ou relatif, correspond. (Hérité de Control.)
Méthode protégéeMarkAsDataBoundDéfinit l'état du contrôle dans l'état d'affichage comme lié avec succès aux données. (Hérité de HierarchicalDataBoundControl.)
Méthode protégéeMemberwiseCloneCrée une copie superficielle de l'objet Object actif. (Hérité de Object.)
Méthode publiqueMergeStyleCopie tous les éléments non vides du style spécifié vers le contrôle Web, mais ne remplace aucun élément de style existant du contrôle. Cette méthode est principalement utilisée par des développeurs de contrôles. (Hérité de WebControl.)
Méthode protégéeOnBubbleEventInfrastructure. Détermine si l'événement du contrôle Menu est passé dans la hiérarchie des contrôles serveur de l'interface utilisateur de la page. (Substitue Control..::.OnBubbleEvent(Object, EventArgs).)
Méthode protégéeOnDataBindingDéclenche l'événement DataBinding. (Substitue Control..::.OnDataBinding(EventArgs).)
Méthode protégéeOnDataBoundDéclenche l'événement DataBound. (Hérité de BaseDataBoundControl.)
Méthode protégéeOnDataPropertyChangedAppelé lorsque l'une des propriétés d'identification de la source de données de base est modifiée, pour rétablir la liaison du contrôle lié aux données à ses données. (Hérité de HierarchicalDataBoundControl.)
Méthode protégéeOnDataSourceChangedAppelé lorsque l'instance de IHierarchicalDataSource avec laquelle fonctionne le contrôle lié aux données déclenche l'événement DataSourceChanged. (Hérité de HierarchicalDataBoundControl.)
Méthode protégéeOnInitInfrastructure. Déclenche l'événement Init. (Substitue BaseDataBoundControl..::.OnInit(EventArgs).)
Méthode protégéeOnLoadGère l'événement Load. (Hérité de HierarchicalDataBoundControl.)
Méthode protégéeOnMenuItemClickDéclenche l'événement MenuItemClick.
Méthode protégéeOnMenuItemDataBoundDéclenche l'événement MenuItemDataBound.
Méthode protégéeOnPagePreLoadDéfinit l'état initialisé du contrôle lié aux données avant que le contrôle ne soit chargé. (Hérité de HierarchicalDataBoundControl.)
Méthode protégéeOnPreRenderInfrastructure. Déclenche l'événement PreRender. (Substitue BaseDataBoundControl..::.OnPreRender(EventArgs).)
Méthode protégéeOnUnloadDéclenche l'événement Unload. (Hérité de Control.)
Méthode protégéeOpenFileObtient un Stream utilisé pour lire un fichier. (Hérité de Control.)
Méthode protégéePerformDataBindingInfrastructure. Lie les éléments de la source de données aux éléments de menu dans le contrôle Menu. (Substitue HierarchicalDataBoundControl..::.PerformDataBinding()()().)
Méthode protégéePerformSelectRécupère les données de la source de données associée. (Hérité de HierarchicalDataBoundControl.)
Méthode protégéeRaiseBubbleEventAssigne les sources éventuelles de l'événement et ses informations au parent du contrôle. (Hérité de Control.)
Méthode protégéeRaisePostBackEventTraite un événement déclenché lorsqu'un formulaire est publié sur le serveur.
Méthode protégéeRemovedControlAppelée après la suppression d'un contrôle enfant dans la collection Controls de l'objet Control. (Hérité de Control.)
Méthode protégéeRenderInfrastructure. Génère le rendu du contrôle de menu sur le navigateur du client. (Substitue WebControl..::.Render(HtmlTextWriter).)
Méthode publiqueRenderBeginTagAjoute des attributs de balise et écrit le balisage de la balise d'ouverture du contrôle dans le flux de sortie émis vers le navigateur ou l'appareil. (Substitue WebControl..::.RenderBeginTag(HtmlTextWriter).)
Méthode protégéeRenderChildrenRenvoie le contenu des enfants d'un contrôle serveur dans un objet HtmlTextWriter fourni, qui écrit le contenu à rendre sur le client. (Hérité de Control.)
Méthode protégéeRenderContentsInfrastructure. Ce membre se substitue à RenderContents. (Substitue WebControl..::.RenderContents(HtmlTextWriter).)
Méthode publiqueRenderControl(HtmlTextWriter)Renvoie le contenu du contrôle serveur dans un objet HtmlTextWriter fourni et stocke des informations de traçage au sujet du contrôle si le traçage est activé. (Hérité de Control.)
Méthode protégéeRenderControl(HtmlTextWriter, ControlAdapter)Génère le contenu du contrôle serveur dans un objet HtmlTextWriter à l'aide d'un objet ControlAdapter fourni. (Hérité de Control.)
Méthode publiqueRenderEndTagEffectue le balisage final et écrit la balise de fermeture HTML du contrôle dans le flux de sortie émis vers le navigateur ou l'appareil. (Substitue WebControl..::.RenderEndTag(HtmlTextWriter).)
Méthode protégéeResolveAdapterObtient l'adaptateur de contrôles responsable du rendu du contrôle spécifié. (Hérité de Control.)
Méthode publiqueResolveClientUrlObtient une URL qui peut être utilisée par le navigateur. (Hérité de Control.)
Méthode publiqueResolveUrlConvertit une URL en une URL que le client soit en mesure d'utiliser. (Hérité de Control.)
Méthode protégéeSaveControlStateInfrastructure. Enregistre l'état des propriétés du contrôle Menu qui doivent être persistants. (Substitue Control..::.SaveControlState()()().)
Méthode protégéeSaveViewStateEnregistre l'état du contrôle Menu. (Substitue WebControl..::.SaveViewState()()().)
Méthode protégéeSetDesignModeStateDéfinit les données au moment du design pour le contrôle Menu. (Substitue Control..::.SetDesignModeState(IDictionary).)
Méthode protégéeSetItemDataBoundDéfinit la propriété DataBound de l'objet MenuItem spécifié avec la valeur spécifiée.
Méthode protégéeSetItemDataItemDéfinit la propriété DataItem de l'objet MenuItem spécifié avec la valeur spécifiée.
Méthode protégéeSetItemDataPathDéfinit la propriété DataPath de l'objet MenuItem spécifié avec la valeur spécifiée.
Méthode publiqueSetRenderMethodDelegateInfrastructure. Assigne un délégué de gestionnaires d'événements pour générer le rendu du contrôle serveur et de son contenu dans son contrôle parent. (Hérité de Control.)
Méthode publiqueToStringRetourne une chaîne qui représente l'objet actuel. (Hérité de Object.)
Méthode protégéeTrackViewStateSuit les modifications d'état d'affichage du contrôle Menu afin qu'elles puissent être stockées dans l'objet StateBag du contrôle. Cet objet est accessible à l'aide de la propriété ViewState. (Substitue WebControl..::.TrackViewState()()().)
Méthode protégéeValidateDataSourceVérifie que l'objet auquel un contrôle lié aux données se lie est un objet avec qui il peut fonctionner. (Hérité de HierarchicalDataBoundControl.)
Début
  NomDescription
Événement publicDataBindingSe produit lorsque le contrôle serveur se lie à une source de données. (Hérité de Control.)
Événement publicDataBoundSe produit après la liaison du contrôle serveur à une source de données. (Hérité de BaseDataBoundControl.)
Événement publicDisposedSe produit lorsqu'un contrôle serveur est libéré de la mémoire, ce qui constitue la dernière étape du cycle de vie d'un contrôle serveur en cas de demande d'une page ASP.NET. (Hérité de Control.)
Événement publicInitSe produit lorsque le contrôle serveur est initialisé, ce qui constitue la première étape de son cycle de vie. (Hérité de Control.)
Événement publicLoadSe produit lorsque le contrôle serveur est chargé dans l'objet Page. (Hérité de Control.)
Événement publicMenuItemClickSe produit suite à un clic sur un élément de menu d'un contrôle Menu.
Événement publicMenuItemDataBoundSe produit lorsqu'un élément de menu d'un contrôle Menu est lié aux données.
Événement publicPreRenderSe produit après le chargement de l'objet Control mais avant le rendu. (Hérité de Control.)
Événement publicUnloadSe produit lorsque le contrôle serveur est déchargé de la mémoire. (Hérité de Control.)
Début
  NomDescription
Méthode d'extension publiqueEnableDynamicData(Type)Surchargé. Active le comportement Dynamic Data pour le contrôle de données spécifié. (Défini par DataControlExtensions.)
Méthode d'extension publiqueEnableDynamicData(Type, Object)Surchargé. Active le comportement Dynamic Data pour le contrôle de données spécifié. (Défini par DataControlExtensions.)
Méthode d'extension publiqueEnableDynamicData(Type, IDictionary<(Of <(String, Object>)>))Surchargé. Active le comportement Dynamic Data pour le contrôle de données spécifié. (Défini par DataControlExtensions.)
Méthode d'extension publiqueEnablePersistedSelectionRend la sélection persistante dans les contrôles de données qui prennent en charge la sélection et la pagination. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueFindDataSourceControlRetourne la source de données associée au contrôle de données pour le contrôle spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueFindFieldTemplateRetourne le modèle de champ pour la colonne spécifiée dans le conteneur d'attribution de noms du contrôle spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueFindMetaTableRetourne l'objet Metatable pour le contrôle de données conteneur. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueGetDefaultValuesObtient la collection des valeurs par défaut pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueGetMetaTableObtient les métadonnées de table pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueSetMetaTable(MetaTable)Surchargé. Définit les métadonnées de table pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueSetMetaTable(MetaTable, IDictionary<(Of <(String, Object>)>))Surchargé. Définit les métadonnées de table et le mappage des valeurs par défaut pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueSetMetaTable(MetaTable, Object)Surchargé. Définit les métadonnées de table et le mappage des valeurs par défaut pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueTryGetMetaTableDétermine si des métadonnées de table sont disponibles. (Défini par DynamicDataExtensions.)
Début
  NomDescription
Champ publicMembre statiqueMenuItemClickCommandNameContient le nom de la commande.
Début
  NomDescription
Implémentation d'interface expliciteMéthode privéeIAttributeAccessor..::.GetAttributeInfrastructure. Obtient un attribut du contrôle Web avec le nom spécifié. (Hérité de WebControl.)
Implémentation d'interface expliciteMéthode privéeIAttributeAccessor..::.SetAttributeAffecte au nom et à la valeur spécifiés un attribut du contrôle Web. (Hérité de WebControl.)
Implémentation d'interface explicitePropriété privéeIControlBuilderAccessor..::.ControlBuilderPour obtenir une description de ce membre, consultez IControlBuilderAccessor..::.ControlBuilder. (Hérité de Control.)
Implémentation d'interface expliciteMéthode privéeIControlDesignerAccessor..::.GetDesignModeStatePour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.GetDesignModeState. (Hérité de Control.)
Implémentation d'interface expliciteMéthode privéeIControlDesignerAccessor..::.SetDesignModeStatePour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.SetDesignModeState. (Hérité de Control.)
Implémentation d'interface expliciteMéthode privéeIControlDesignerAccessor..::.SetOwnerControlInfrastructure. Pour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.SetOwnerControl. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIControlDesignerAccessor..::.UserDataPour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.UserData. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIDataBindingsAccessor..::.DataBindingsPour obtenir une description de ce membre, consultez IDataBindingsAccessor..::.DataBindings. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIDataBindingsAccessor..::.HasDataBindingsPour obtenir une description de ce membre, consultez IDataBindingsAccessor..::.HasDataBindings. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIExpressionsAccessor..::.ExpressionsPour obtenir une description de ce membre, consultez IExpressionsAccessor..::.Expressions. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIExpressionsAccessor..::.HasExpressionsPour obtenir une description de ce membre, consultez IExpressionsAccessor..::.HasExpressions. (Hérité de Control.)
Implémentation d'interface expliciteMéthode privéeIParserAccessor..::.AddParsedSubObjectPour obtenir une description de ce membre, consultez IParserAccessor..::.AddParsedSubObject. (Hérité de Control.)
Implémentation d'interface expliciteMéthode privéeIPostBackEventHandler..::.RaisePostBackEventInfrastructure. Traite un événement déclenché lorsqu'un formulaire est publié sur le serveur.
Début

Dans cette rubrique :

Introduction

Le contrôle Menu permet d'afficher un menu dans une page Web ASP.NET et est souvent associé à un contrôle SiteMapDataSource pour parcourir un site Web. Le contrôle Menu prend en charge les fonctionnalités suivantes :

  • Liaison de données qui permet aux éléments de menu du contrôle d'être liés aux sources de données hiérarchiques.

  • Navigation de site via l'intégration avec le contrôle SiteMapDataSource.

  • Accès par programme au modèle objet Menu pour créer des menus de manière dynamique, remplir les éléments de menu, définir les propriétés, etc.

  • Apparence personnalisable grâce aux thèmes, images, styles et modèles définis par l'utilisateur.

Lorsque l'utilisateur clique sur un élément de menu, le contrôle Menu peut naviguer vers une page Web liée ou simplement effectuer une publication sur le serveur. Si la propriété NavigateUrl d'un élément de menu est définie, le contrôle Menu navigue vers la page liée ; sinon, il publie la page sur le serveur pour traitement. Par défaut, une page liée s'affiche dans la même fenêtre ou frame que le contrôle Menu. Pour afficher le contenu lié dans une fenêtre ou frame différent, utilisez la propriété Target du contrôle Menu.

RemarqueRemarque

La propriété Target affecte chaque élément de menu du contrôle. Pour spécifier une fenêtre ou frame d'un élément de menu, définissez directement la propriété Target de l'objet MenuItem.

Le contrôle Menu affiche deux types de menus : un menu statique et un menu dynamique. Le menu statique s'affiche toujours dans un contrôle Menu. Par défaut, les éléments de menu au niveau racine (niveau 0) s'affichent dans le menu statique. Vous pouvez afficher des niveaux de menu supplémentaires (sous-menus statiques) dans le menu statique en définissant la propriété StaticDisplayLevels. Les éléments de menu (le cas échéant) avec un niveau supérieur à la valeur spécifiée par la propriété StaticDisplayLevels s'affichent dans un menu dynamique. Un menu dynamique n'apparaît que lorsque l'utilisateur positionne le pointeur de la souris sur l'élément de menu parent qui contient un sous-menu dynamique. Les menus dynamiques disparaissent automatiquement au bout d'un certain temps. Utilisez la propriété DisappearAfter pour spécifier la durée.

RemarqueRemarque

Un menu dynamique disparaît également lorsque l'utilisateur clique en dehors du menu.

Vous pouvez également limiter le nombre de niveaux affiché dans un menu dynamique en définissant la propriété MaximumDynamicDisplayLevels. Les niveaux de menu supérieurs à la valeur spécifiée sont ignorés.

RemarqueRemarque

Le contrôle Menu n'est pas conçu pour être utilisé dans un contrôle UpdatePanel. Vous pouvez uniquement ajouter le contrôle Menu à une page en dehors d'un contrôle UpdatePanel. Les contrôles UpdatePanel permettent de mettre à jour des zones sélectionnées sur une page plutôt que la page entière avec une publication. Pour plus d'informations, consultez Vue d'ensemble du contrôle UpdatePanel et Vue d'ensemble du rendu de page partielle.

Éléments de menu

Un contrôle Menu est composé d'une arborescence d'éléments de menu représentée par les objets MenuItem. Les éléments de menu du niveau supérieur (niveau 0) sont appelés éléments de menu racine. Un élément de menu ayant un élément de menu parent est appelé élément de menu enfant. Tous les éléments de menu racine sont stockés dans la collection Items. Les éléments de menu enfants sont stockés dans une collection ChildItems d'un élément de menu parent.

Chaque élément de menu a un Text et une propriété Value. La valeur de la propriété Text s'affiche dans le contrôle Menu, tandis que la propriété Value permet de stocker toutes les données supplémentaires relatives à l'élément de menu, telles que les données passées à l'événement de publication associé à l'élément de menu. Lorsque vous cliquez dessus, un élément de menu peut naviguer vers une autre page Web indiquée par la propriété NavigateUrl.

RemarqueRemarque

Si la propriété NavigateUrl d'un élément de menu n'est pas définie, le contrôle Menu soumet simplement la page au serveur pour traitement lorsque vous cliquez sur l'élément de menu.

Vous pouvez aussi afficher éventuellement une image dans un élément de menu en définissant la propriété ImageUrl.

Pour plus d'informations sur les éléments de menu, consultez MenuItem.

Données statiques

Le modèle de données le plus simple du contrôle Menu correspond aux éléments de menu statiques. Pour afficher les éléments de menu statiques à l'aide d'une syntaxe déclarative, commencez par imbriquer les balises <Items> d'ouverture et de fermeture entre les balises d'ouverture et de fermeture du contrôle Menu. Ensuite, créez la structure de menu en imbriquant les éléments <asp:MenuItem> entre les balises <Items> d'ouverture et de fermeture. Chaque élément <asp:MenuItem> représente un élément de menu du contrôle et correspond à un objet MenuItem. Vous pouvez définir les propriétés de chaque élément de menu en définissant les attributs de son élément <asp:MenuItem>. Pour créer des éléments de sous-menu, imbriquez des éléments <asp:MenuItem> supplémentaires entre les balises <asp:MenuItem> d'ouverture et de fermeture de l'élément de menu parent.

Liaison de données

Le contrôle Menu peut utiliser n'importe quel contrôle de source de données hiérarchique, par exemple un contrôle XmlDataSource ou un contrôle SiteMapDataSource. Pour effectuer une liaison à un contrôle de source de données hiérarchique, affectez à la propriété DataSourceID du contrôle Menu la valeur ID du contrôle de source de données. Le contrôle Menu se lie automatiquement au contrôle de source de données spécifié. Il s'agit de la méthode recommandée de liaison aux données.

Lorsque vous effectuez une liaison à une source de données où chaque élément de données contient plusieurs propriétés (tel qu'un élément XML avec plusieurs attributs), un élément de menu affiche la valeur retournée par la méthode ToString de l'élément de données par défaut. Dans le cas d'un élément XML, l'élément de menu affiche le nom de l'élément, lequel affiche la structure sous-jacente de l'arborescence de menu, mais qui n'est pas très utile par ailleurs. Vous pouvez lier un élément de menu à une propriété d'élément de données spécifique en utilisant la collection DataBindings pour spécifier des liaisons d'éléments de menu. La collection DataBindings contient des objets MenuItemBinding qui définissent la relation entre un élément de données et l'élément de menu auquel il est lié. Vous pouvez spécifier les critères de liaison et la propriété de l'élément de données à afficher dans le nœud. Pour plus d'informations sur les liaisons d'éléments de menu, consultez MenuItemBinding.

Vous ne pouvez pas créer de nœud vide dans un contrôle Menu en affectant aux propriétés Text ou TextField la valeur d'une chaîne vide (""). L'affectation de la valeur d'une chaîne vide à ces propriétés équivaut à ne pas définir les propriétés. Dans ce cas, le contrôle Menu crée une liaison par défaut à l'aide de la propriété DataSource. Pour plus d'informations, consultez Liaison à des bases de données.

Personnalisation de l'interface utilisateur

Il existe plusieurs manières de personnaliser l'apparence du contrôle Menu. En premier lieu, vous pouvez spécifier si le contrôle Menu est rendu horizontalement ou verticalement en définissant la propriété Orientation. Vous pouvez également spécifier un style différent (par exemple une taille et une couleur de police) pour chacun des types d'éléments de menu.

Si vous utilisez des feuilles de style en cascade (CSS, Cascading Style Sheets) pour personnaliser l'apparence du contrôle, utilisez des styles intralignes ou un fichier CSS distinct, mais pas les deux en même temps. L'utilisation conjointe des styles intralignes et d'un fichier CSS distinct peut entraîner des résultats inattendus. Pour plus d'informations sur l'utilisation des feuilles de style avec des contrôles, consultez Contrôles serveur Web ASP.NET et styles CSS.

Le tableau suivant répertorie les styles d'élément de menu disponibles.

Propriété de style d'élément de menu

Description

DynamicHoverStyle

Paramètres de style d'un élément de menu dynamique lorsque le pointeur de la souris est positionné sur lui.

DynamicMenuItemStyle

Paramètres de style d'un élément de menu dynamique.

DynamicMenuStyle

Paramètres de style d'un menu dynamique.

DynamicSelectedStyle

Paramètres de style de l'élément de menu dynamique actuellement sélectionné.

StaticHoverStyle

Paramètres de style d'un élément de menu statique lorsque le pointeur de la souris est positionné sur lui.

StaticMenuItemStyle

Paramètres de style d'un élément de menu statique.

StaticMenuStyle

Paramètres de style d'un menu statique.

StaticSelectedStyle

Paramètres de style de l'élément de menu statique actuellement sélectionné.

Au lieu de définir les propriétés de style, vous pouvez spécifier les styles appliqués aux éléments de menu en fonction de leur niveau à l'aide des collections de styles suivantes.

Collections de styles de niveau

Description

LevelMenuItemStyles

Collection d'objets MenuItemStyle qui contrôlent le style des éléments de menu en fonction du niveau.

LevelSelectedStyles

Collection d'objets MenuItemStyle qui contrôlent le style des éléments de menu sélectionnés en fonction du niveau.

LevelSubMenuStyles

Collection d'objets MenuItemStyle qui contrôlent le style des éléments de sous-menu en fonction du niveau.

Le premier style de la collection correspond au style des éléments de menu au premier niveau de profondeur de l'arborescence du menu. Le deuxième style de la collection correspond au style des éléments de menu au deuxième niveau de profondeur de l'arborescence du menu, et ainsi de suite. Ce mécanisme est le plus souvent utilisé pour générer des menus de navigation de style table des matières où les éléments de menu, à une certaine profondeur, doivent avoir la même apparence, qu'ils aient ou non des sous-menus.

RemarqueRemarque

Si vous utilisez l'une des collections de styles de niveau répertoriées dans le tableau précédent pour définir le style du contrôle Menu, ces paramètres de style substituent les propriétés de style de l'élément de menu.

La personnalisation des images affichées dans le contrôle Menu est une autre manière de modifier l'apparence du contrôle. Vous pouvez spécifier votre propre image personnalisée pour les différentes parties du contrôle en définissant les propriétés affichées dans le tableau suivant.

Propriété d'image

Description

DynamicBottomSeparatorImageUrl

Image facultative affichée en bas d'un élément de menu dynamique pour le séparer d'autres éléments de menu.

DynamicPopOutImageUrl

Image facultative affichée dans un élément de menu dynamique pour indiquer qu'il a un sous-menu.

DynamicTopSeparatorImageUrl

Image facultative affichée en haut d'un élément de menu dynamique pour le séparer d'autres éléments de menu.

ScrollDownImageUrl

Image affichée en bas d'un élément de menu pour indiquer que l'utilisateur peut faire défiler les éléments vers le bas pour afficher des éléments de menu supplémentaires.

ScrollUpImageUrl

Image affichée en haut d'un élément de menu pour indiquer que l'utilisateur peut faire défiler les éléments vers le haut pour afficher des éléments de menu supplémentaires.

StaticBottomSeparatorImageUrl

Image facultative affichée en bas d'un élément de menu statique pour le séparer d'autres éléments de menu.

StaticPopOutImageUrl

Image facultative affichée dans un élément de menu statique pour indiquer qu'il a un sous-menu.

StaticTopSeparatorImageUrl

Image facultative affichée en haut d'un élément de menu statique pour le séparer d'autres éléments de menu.

Pour un contrôle complet de l'interface utilisateur, vous pouvez définir vos propres modèles personnalisés pour le contrôle Menu à l'aide des propriétés de modèle suivantes.

Propriété du modèle

Description

DynamicItemTemplate

Modèle qui contient le contenu personnalisé à rendre pour un élément de menu dynamique.

StaticItemTemplate

Modèle qui contient le contenu personnalisé à rendre pour un élément de menu statique.

Vous pouvez contrôler la position verticale et horizontale d'un menu dynamique relatif à son élément de menu parent en définissant respectivement les propriétés DynamicVerticalOffset et DynamicHorizontalOffset. Pour contrôler la mise en retrait des éléments de sous-menu statiques d'un menu statique, utilisez la propriété StaticSubMenuIndent.

Événements

Le contrôle Menu fournit plusieurs événements que vous pouvez programmer. Cela vous permet d'exécuter une routine personnalisée lorsqu'un événement se produit. Le tableau suivant répertorie les événements pris en charge.

Événement

Description

MenuItemClick

Se produit lorsqu'un utilisateur clique sur un élément de menu. Cet événement est utilisé couramment pour synchroniser un contrôle Menu avec un autre contrôle de la page.

MenuItemDataBound

Se produit lorsqu'un élément de menu est lié à des données. Cet événement est utilisé couramment pour modifier un élément de menu avant qu'il soit rendu dans un contrôle Menu.

Accessibilité

Pour plus d'informations sur la configuration de ce contrôle afin qu'il génère des balises conforment aux standards d'accessibilité, consultez Accessibilité dans Visual Studio et ASP.NET et Contrôles et accessibilité ASP.NET.

Syntaxe déclarative

<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
Comment : afficher des données sitemap dans des contrôles serveur Web non hiérarchiquesGénération d'applications Web ASP.NET
Comment : afficher des données sitemap dans des contrôles serveur Web non hiérarchiquesGénération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter la navigation de site simpleGénération d'applications Web ASP.NET
Comment : ajouter la navigation de site simpleGénération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter la navigation de site simpledv_vwdcon
Comment : configurer plusieurs plans de sites et fournisseurs sitemapGénération d'applications Web ASP.NET
Comment : configurer plusieurs plans de sites et fournisseurs sitemapGénération d'applications Web ASP.NET dans Visual Studio
Comment : énumérer par programme des nœuds sitemapGénération d'applications Web ASP.NET
Comment : énumérer par programme des nœuds sitemapGénération d'applications Web ASP.NET dans Visual Studio
Comment : filtrer les nœuds récupérés par les contrôles serveur Web SiteMapDataSourceGénération d'applications Web ASP.NET
Comment : filtrer les nœuds récupérés par les contrôles serveur Web SiteMapDataSourceGénération d'applications Web ASP.NET dans Visual Studio
Comment : implémenter des fournisseurs sitemap ASP.NETGénération d'applications Web ASP.NET
Comment : implémenter des fournisseurs sitemap ASP.NETGénération d'applications Web ASP.NET dans Visual Studio
Comment : personnaliser l'apparence des contrôles serveur Web SiteMapPathGénération d'applications Web ASP.NET
Comment : personnaliser l'apparence des contrôles serveur Web SiteMapPathGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : affichage d'un menu sur des pages WebGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : affichage d'un menu sur des pages WebGénération d'applications à l'aide de Visual Web Developer
Procédure pas à pas : ajout de la navigation de site à un site WebGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : ajout de la navigation de site à un site WebGénération d'applications à l'aide de Visual Web Developer
Procédure pas à pas : contrôle des menus ASP.NET par programmeGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : contrôle des menus ASP.NET par programmeGénération d'applications Web ASP.NET dans Visual Studio

Un projet de site Web Visual Studio contenant du code source est disponible pour accompagner cette rubrique : Download.

L'exemple de code suivant montre comment créer un contrôle Menu avec les éléments de menu statiques à l'aide d'une syntaxe déclarative.

Visual Basic

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu Declarative Example</title>
</head>

  <body>
    <form id="form1" runat="server">

      <h3>Menu Declarative Example</h3>

      <!-- Use declarative syntax to create the   -->
      <!-- menu structure. Submenu items are      -->
      <!-- created by nesting them in parent menu -->
      <!-- items.                                 -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        font-names="Arial" 
        target="_blank"  
        runat="server">

        <staticmenuitemstyle backcolor="LightSteelBlue"
          forecolor="Black"/>
        <statichoverstyle backcolor="LightSkyBlue"/>
        <dynamicmenuitemstyle backcolor="Black"
          forecolor="Silver"/>
        <dynamichoverstyle backcolor="LightSkyBlue"
          forecolor="Black"/>

        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Home"
            tooltip="Home">
            <asp:menuitem navigateurl="Music.aspx"
              text="Music"
              tooltip="Music">
              <asp:menuitem navigateurl="Classical.aspx" 
                text="Classical"
                tooltip="Classical"/>
              <asp:menuitem navigateurl="Rock.aspx"
                text="Rock"
                tooltip="Rock"/>
              <asp:menuitem navigateurl="Jazz.aspx"
                text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem navigateurl="Movies.aspx"
              text="Movies"
              tooltip="Movies">
              <asp:menuitem navigateurl="Action.aspx"
                text="Action"
                tooltip="Action"/>
              <asp:menuitem navigateurl="Drama.aspx"
                text="Drama"
                tooltip="Drama"/>
              <asp:menuitem navigateurl="Musical.aspx"
                text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>

      </asp:menu>

    </form>
  </body>
</html>

C#

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu Declarative Example</title>
</head>

  <body>
    <form id="form1" runat="server">

      <h3>Menu Declarative Example</h3>

      <!-- Use declarative syntax to create the   -->
      <!-- menu structure. Submenu items are      -->
      <!-- created by nesting them in parent menu -->
      <!-- items.                                 -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        font-names="Arial" 
        target="_blank"  
        runat="server">

        <staticmenuitemstyle backcolor="LightSteelBlue"
          forecolor="Black"/>
        <statichoverstyle backcolor="LightSkyBlue"/>
        <dynamicmenuitemstyle backcolor="Black"
          forecolor="Silver"/>
        <dynamichoverstyle backcolor="LightSkyBlue"
          forecolor="Black"/>

        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Home"
            tooltip="Home">
            <asp:menuitem navigateurl="Music.aspx"
              text="Music"
              tooltip="Music">
              <asp:menuitem navigateurl="Classical.aspx" 
                text="Classical"
                tooltip="Classical"/>
              <asp:menuitem navigateurl="Rock.aspx"
                text="Rock"
                tooltip="Rock"/>
              <asp:menuitem navigateurl="Jazz.aspx"
                text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem navigateurl="Movies.aspx"
              text="Movies"
              tooltip="Movies">
              <asp:menuitem navigateurl="Action.aspx"
                text="Action"
                tooltip="Action"/>
              <asp:menuitem navigateurl="Drama.aspx"
                text="Drama"
                tooltip="Drama"/>
              <asp:menuitem navigateurl="Musical.aspx"
                text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>

      </asp:menu>

    </form>
  </body>
</html>

L'exemple de code suivant montre comment lier le contrôle Menu à un contrôle SiteMapDataSource. Pour que cet exemple fonctionne, vous devez copier les données du plan de site ci-dessous dans un fichier nommé Web.sitemap.

Visual Basic

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu DataBinding Example</title>
</head>

  <body>
    <form id="form1" runat="server">

      <h3>Menu DataBinding Example</h3>

      <!-- Bind the Menu control to a SiteMapDataSource control.  -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        font-names="Arial" 
        target="_blank"
        datasourceid="MenuSource"   
        runat="server">

        <staticmenuitemstyle backcolor="LightSteelBlue"
          forecolor="Black"/>
        <statichoverstyle backcolor="LightSkyBlue"/>
        <dynamicmenuitemstyle backcolor="Black"
          forecolor="Silver"/>
        <dynamichoverstyle backcolor="LightSkyBlue"
          forecolor="Black"/>

      </asp:menu>

      <asp:SiteMapDataSource id="MenuSource"
        runat="server"/>        

    </form>
  </body>
</html>

C#

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu DataBinding Example</title>
</head>

  <body>
    <form id="form1" runat="server">

      <h3>Menu DataBinding Example</h3>

      <!-- Bind the Menu control to a SiteMapDataSource control.  -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        font-names="Arial" 
        target="_blank"
        datasourceid="MenuSource"   
        runat="server">

        <staticmenuitemstyle backcolor="LightSteelBlue"
          forecolor="Black"/>
        <statichoverstyle backcolor="LightSkyBlue"/>
        <dynamicmenuitemstyle backcolor="Black"
          forecolor="Silver"/>
        <dynamichoverstyle backcolor="LightSkyBlue"
          forecolor="Black"/>

      </asp:menu>

      <asp:SiteMapDataSource id="MenuSource"
        runat="server"/>        

    </form>
  </body>
</html>

Ceci est un exemple de données de plan de site de l'exemple précédent.

<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

Pris en charge dans : 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2

Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Contenu de la communauté   Qu'est-ce que le Contenu de la communauté ?
Ajouter du contenu RSS  Annotations
Processing
© 2012 Microsoft. Tous droits réservés. Conditions d'utilisation | Marques | Confidentialité
Page view tracker