Menu.SelectedValue プロパティ
アセンブリ: System.Web (system.web.dll 内)


SelectedValue プロパティを使用して、選択されたメニュー項目のテキストを簡単に確認できます。選択されたメニュー項目の他のプロパティにアクセスするには、SelectedItem プロパティを使用します。

SelectedValue プロパティを使用して、Menu コントロールの選択されたメニュー項目のテキストを確認する方法のコード例を次に示します。
<%@ Page Language="VB" %> <script runat="server"> Sub NavigationMenu_MenuItemClick(ByVal sender As Object, ByVal e As MenuEventArgs) ' Use the SelectedItem property to retrieve the selected ' menu item. Dim selectedItem As MenuItem = NavigationMenu.SelectedItem Message.Text = "You selected " & _ NavigationMenu.SelectedItem.Text & "." End Sub </script> <html> <body> <form runat="server"> <h3>Menu SelectedItem 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) { // Use the SelectedItem property to retrieve the selected // menu item. MenuItem selectedItem = NavigationMenu.SelectedItem; Message.Text = "You selected " + NavigationMenu.SelectedItem.Text + "."; } </script> <html> <body> <form runat="server"> <h3>Menu SelectedItem 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.SelectedValue プロパティを検索する場合は、下記のリンクをクリックしてください。

- Menu.SelectedValue プロパティのページへのリンク