Menu.DisappearAfter 屬性

定義

取得或設定當滑鼠指標不再位於功能表上之後,動態功能表顯示的持續期間。

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

屬性值

當滑鼠指標不再位於功能表上之後,動態功能表顯示的時間長度 (以毫秒為單位)。 預設值為 500。

屬性

例外狀況

選取的值小於 -1。

範例

下列程式碼範例示範如何使用 DisappearAfter 屬性來指定當使用者將滑鼠指標移開功能表之後,動態功能表應該消失超過兩秒。


<%@ 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>

備註

根據預設,當滑鼠指標不再位於功能表上方時,動態功能表會自動在某個持續時間後消失。 DisappearAfter使用 屬性來指定持續時間。

注意

如果使用者按一下功能表外部,動態功能表就會立即消失。

您也可以將此屬性設定為 -1,以指定動態功能表絕對不會自動消失。 在此情況下,只有在使用者按一下功能表外部時,動態功能表項目才會消失。

這個屬性無法由佈景主題或樣式表主題設定。 如需詳細資訊,請參閱 ThemeableAttributeASP.NET 主題和麵板

適用於

另請參閱