Menu.MenuItemClick イベント
アセンブリ: System.Web (system.web.dll 内)

public: event MenuEventHandler^ MenuItemClick { void add (MenuEventHandler^ value); void remove (MenuEventHandler^ value); }

MenuItemClick イベントは、Menu コントロールのメニュー項目がクリックされると発生します。これにより、このイベントが発生するたびにカスタム ルーチン (コントロールをページの別のコントロールと同期するなど) を実行するイベント ハンドラを提供できます。
MenuEventArgs オブジェクトはイベント ハンドラに渡され、これによりイベントを発生させたメニュー項目のプロパティにアクセスできます。
イベント処理の詳細については、「イベントの利用」を参照してください。

ユーザーが選択したメニュー項目のテキストを表示する MenuItemClick イベントのイベント ハンドラを作成する方法のコード例を次に示します。
<%@ Page Language="VB" %> <script runat="server"> Sub NavigationMenu_MenuItemClick(ByVal sender As Object, ByVal e As MenuEventArgs) ' Display the text of the menu item selected by the user. Message.Text = "You selected " & _ e.Item.Text & "." End Sub </script> <html> <body> <form runat="server"> <h3>Menu MenuItemClick Example</h3> <asp:menu id="NavigationMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" onmenuitemclick="NavigationMenu_MenuItemClick" runat="server"> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> <hr/> <asp:label id="Message" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void NavigationMenu_MenuItemClick(Object sender, MenuEventArgs e) { // Display the text of the menu item selected by the user. Message.Text = "You selected " + e.Item.Text + "."; } </script> <html> <body> <form runat="server"> <h3>Menu MenuItemClick Example</h3> <asp:menu id="NavigationMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" onmenuitemclick="NavigationMenu_MenuItemClick" runat="server"> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> <hr/> <asp:label id="Message" runat="server"/> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からMenu.MenuItemClick イベントを検索する場合は、下記のリンクをクリックしてください。

- Menu.MenuItemClick イベントのページへのリンク