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 使用して、ユーザーがマウス ポインターをメニューから 2 秒以上離した後に動的メニューを非表示にするように指定する方法を示します。


<%@ 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 に設定することで、動的メニューが自動的に表示されないように指定することもできます。 この場合、動的メニュー項目は、ユーザーがメニューの外側をクリックした場合にのみ表示されなくなります。

このプロパティは、テーマまたはスタイル シート テーマによって設定することはできません。 詳細については、「テーマとスキンの ASP.NET」を参照してくださいThemeableAttribute

適用対象

こちらもご覧ください