Menu.DisappearAfter Właściwość

Definicja

Pobiera lub ustawia czas trwania wyświetlania menu dynamicznego po tym, jak wskaźnik myszy nie jest już umieszczony w menu.

public:
 property int DisappearAfter { int get(); void set(int value); };
[System.Web.UI.Themeable(false)]
public int DisappearAfter { get; set; }
[<System.Web.UI.Themeable(false)>]
member this.DisappearAfter : int with get, set
Public Property DisappearAfter As Integer

Wartość właściwości

Int32

Czas (w milisekundach) menu dynamiczne jest wyświetlane po tym, jak wskaźnik myszy nie jest już umieszczony nad menu. Wartość domyślna to 500.

Atrybuty

Wyjątki

Wybrana wartość jest mniejsza niż -1.

Przykłady

Poniższy przykład kodu pokazuje, jak za pomocą DisappearAfter właściwości określić, że menu dynamiczne powinno zniknąć po tym, jak użytkownik przesuwa wskaźnik myszy z menu przez ponad dwie sekundy.


<%@ 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 DisappearAfter Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu DisappearAfter Example</h3>
    
      <!-- Use the DisappearAfter property to  -->
      <!-- hide the dynamic menu items if the  -->
      <!-- user moves the mouse pointer away   -->
      <!-- from the menu for two seconds.      -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="1"
        orientation="Vertical"   
        runat="server">
      
        <items>
          <asp:menuitem navigateurl="~\Home.aspx" 
            text="Home"/>
          <asp:menuitem navigateurl="~\Music.aspx"
            text="Music">
            <asp:menuitem navigateurl="~\Classical.aspx" 
              text="Classical"/>
            <asp:menuitem navigateurl="~\Rock.aspx"
              text="Rock"/>
            <asp:menuitem navigateurl="~\Jazz.aspx"
              text="Jazz"/>
          </asp:menuitem>
          <asp:menuitem navigateurl="~\Movies.aspx"
            text="Movies">
            <asp:menuitem navigateurl="~\Action.aspx"
              text="Action"/>
            <asp:menuitem navigateurl="~\Drama.aspx"
              text="Drama"/>
            <asp:menuitem navigateurl="~\SciFi.aspx"
              text="Science Fiction"/>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>Menu DisappearAfter Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu DisappearAfter Example</h3>
    
      <!-- Use the DisappearAfter property to  -->
      <!-- hide the dynamic menu items if the  -->
      <!-- user moves the mouse pointer away   -->
      <!-- from the menu for two seconds.      -->
      <asp:menu id="NavigationMenu"
        disappearafter="2000"
        staticdisplaylevels="1"
        orientation="Vertical"   
        runat="server">
      
        <items>
          <asp:menuitem navigateurl="~\Home.aspx" 
            text="Home"/>
          <asp:menuitem navigateurl="~\Music.aspx"
            text="Music">
            <asp:menuitem navigateurl="~\Classical.aspx" 
              text="Classical"/>
            <asp:menuitem navigateurl="~\Rock.aspx"
              text="Rock"/>
            <asp:menuitem navigateurl="~\Jazz.aspx"
              text="Jazz"/>
          </asp:menuitem>
          <asp:menuitem navigateurl="~\Movies.aspx"
            text="Movies">
            <asp:menuitem navigateurl="~\Action.aspx"
              text="Action"/>
            <asp:menuitem navigateurl="~\Drama.aspx"
              text="Drama"/>
            <asp:menuitem navigateurl="~\SciFi.aspx"
              text="Science Fiction"/>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </form>
  </body>
</html>

Uwagi

Domyślnie menu dynamiczne automatycznie zniknie po określonym czasie trwania, gdy wskaźnik myszy nie jest już umieszczony nad menu. Użyj właściwości , DisappearAfter aby określić czas trwania.

Uwaga

Menu dynamiczne zniknie natychmiast, jeśli użytkownik kliknie poza menu.

Możesz również określić, że menu dynamiczne nigdy nie powinno automatycznie zniknąć, ustawiając tę właściwość na -1. W takim przypadku element menu dynamicznego zniknie tylko wtedy, gdy użytkownik kliknie poza menu.

Nie można ustawić tej właściwości według motywów ani motywów arkusza stylów. Aby uzyskać więcej informacji, zobacz ThemeableAttribute i ASP.NET Motywy i skóry.

Dotyczy

Zobacz też