MenuEventArgs Class
TOC
Collapse the table of content
Expand the table of content

MenuEventArgs Class

 

Provides data for the MenuItemClick and MenuItemDataBound events of a Menu control. This class cannot be inherited.

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

System::Object
  System::EventArgs
    System.Web.UI.WebControls::CommandEventArgs
      System.Web.UI.WebControls::MenuEventArgs

public ref class MenuEventArgs sealed : CommandEventArgs

NameDescription
System_CAPS_pubmethodMenuEventArgs(MenuItem^)

Initializes a new instance of the MenuEventArgs class using the specified menu item.

System_CAPS_pubmethodMenuEventArgs(MenuItem^, Object^, CommandEventArgs^)

Initializes a new instance of the MenuEventArgs class using the specified menu item, command source, and event arguments.

NameDescription
System_CAPS_pubpropertyCommandArgument

Gets the argument for the command.(Inherited from CommandEventArgs.)

System_CAPS_pubpropertyCommandName

Gets the name of the command.(Inherited from CommandEventArgs.)

System_CAPS_pubpropertyCommandSource

Gets the Object that raised the event.

System_CAPS_pubpropertyItem

Gets the menu item associated with the event raised.

NameDescription
System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

The MenuEventArgs class is used to store the event data passed to an event handler for the events in the following table.

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.

Depending on the event raised, you can access the menu item clicked by the user or the menu item being bound to data by using the Item property.

For a list of initial property values for an instance of the MenuEventArgs class, see the MenuEventArgs constructor.

The following code example demonstrates how to use the MenuEventArgs object passed to the event handler for the MenuItemDataBound event to modify the properties of a menu item before it is displayed in a Menu control. The ImageUrl property of the Home menu item is set to display an image in that menu item only. For this example to work correctly, you must copy the sample site map data below to a file named Web.sitemap.

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

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

<siteMap>

<siteMapNode url="~\Home.aspx"

title="Home"

description="Home">

<siteMapNode url="~\Music.aspx"

title="Music"

description="Music">

<siteMapNode url="~\Classical.aspx"

title="Classical"

description="Classical"/>

<siteMapNode url="~\Rock.aspx"

title="Rock"

description="Rock"/>

<siteMapNode url="~\Jazz.aspx"

title="Jazz"

description="Jazz"/>

</siteMapNode>

<siteMapNode url="~\Movies.aspx"

title="Movies"

description="Movies">

<siteMapNode url="~\Action.aspx"

title="Action"

description="Action"/>

<siteMapNode url="~\Drama.aspx"

title="Drama"

description="Drama"/>

<siteMapNode url="~\Musical.aspx"

title="Musical"

description="Musical"/>

</siteMapNode>

</siteMapNode>

</siteMap>

.NET Framework
Available since 2.0

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

Return to top
Show:
© 2016 Microsoft