Menu.MenuItemClick Olay

Tanım

Denetimdeki Menu bir menü öğesine tıklandığında gerçekleşir.

public:
 event System::Web::UI::WebControls::MenuEventHandler ^ MenuItemClick;
public event System.Web.UI.WebControls.MenuEventHandler MenuItemClick;
member this.MenuItemClick : System.Web.UI.WebControls.MenuEventHandler 
Public Custom Event MenuItemClick As MenuEventHandler 

Olay Türü

Örnekler

Aşağıdaki kod örneği, kullanıcı tarafından seçilen menü öğesinin MenuItemClick metnini görüntüleyen olay için bir olay işleyicisinin nasıl oluşturulacağını gösterir.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>Menu MenuItemClick Example</title>
</head>
<body>
    <form id="form1" 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="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>Menu MenuItemClick Example</title>
</head>
<body>
    <form id="form1" 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>

Açıklamalar

Denetimde MenuItemClick bir menü öğesine tıklandığında olay tetikleniyor Menu . Bu, bu olay gerçekleştiğinde sayfadaki başka bir denetimle eşitleme gibi özel bir yordam gerçekleştiren bir olay işleyicisi sağlamanıza olanak tanır.

Olayı MenuEventArgs oluşturan menü öğesinin özelliklerine erişmenizi sağlayan olay işleyicisine bir nesne geçirilir.

Olayları işleme hakkında daha fazla bilgi için bkz. Olayları İşleme ve Oluşturma.

Şunlara uygulanır

Ayrıca bkz.