MenuItem.Selectable Propiedad

Definición

Obtiene o establece un valor que indica si el objeto MenuItem se puede seleccionar haciendo clic sobre él.

public:
 property bool Selectable { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(true)]
public bool Selectable { get; set; }
[<System.ComponentModel.Browsable(true)>]
member this.Selectable : bool with get, set
Public Property Selectable As Boolean

Valor de propiedad

Es true si el elemento de menú se puede seleccionar; en caso contrario, es false.

Atributos

Ejemplos

En el ejemplo siguiente se muestra cómo aparece un elemento de menú con la Selectable propiedad establecida false en y funciona en un menú.


<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>Menu Selectable and Enabled properties Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu Selectable and Enabled properties Example</h3>
    Note that Home, set to Selectable=false, is unselectable, but still shows all child items.<br />
    Movies, set to Enabled=false, is unselectable, is greyed out, and does not show child items. <br />
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="1"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <dynamicmenustyle backcolor="LightSkyBlue"
          forecolor="Black"
          borderstyle="Solid"
          borderwidth="1"
          bordercolor="Black" />
      
        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Non-Selectable"
            tooltip="Non-Selectable"
              Selectable="false">
            <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="Disabled"
              tooltip="Disabled"
              Enabled="false">
              <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>

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>Menu Selectable and Enabled properties Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu Selectable and Enabled properties Example</h3>
    Note that Home, set to Selectable=false, is unselectable, but still shows all child items.<br />
    Movies, set to Enabled=false, is unselectable, is greyed out, and does not show child items. <br />
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="1"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <dynamicmenustyle backcolor="LightSkyBlue"
          forecolor="Black"
          borderstyle="Solid"
          borderwidth="1"
          bordercolor="Black" />
      
        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Non-Selectable"
            tooltip="Non-Selectable"
              Selectable="false">
            <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="Disabled"
              tooltip="Disabled"
              Enabled="false">
              <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>

Comentarios

Cuando esta propiedad se establece false en en un elemento de menú, no se produce ninguna acción cuando se hace clic en el elemento de menú (seleccionado). La imagen emergente que indica los elementos de menú secundarios del elemento de menú, si existe, todavía se muestra y está disponible.

Si no desea que aparezcan elementos de menú secundarios para un elemento de menú, establezca la Enabled propiedad falseen .

Selectable solo se aplica a los elementos de menú que se pueden seleccionar, en el sentido de que al hacer clic en un elemento de menú se devuelven y se establece ese elemento en el estado seleccionado. Tenga en cuenta que un elemento de menú que no se puede seleccionar todavía tiene el formato de vínculo. Esto se debe a motivos de accesibilidad, por lo que el elemento de menú puede hacer que se produzca una acción. Además, un elemento de menú, incluso si no se puede seleccionar, puede tener elementos de menú secundarios que se pueden seleccionar o que deben mostrarse.

Si desea impedir que un usuario haga clic en un elemento de menú, realice una de las siguientes acciones:

Se aplica a

Consulte también