Menu.StaticItemFormatString 屬性

定義

取得或設定與靜態顯示之所有功能表項目一起顯示的其他文字。

public:
 property System::String ^ StaticItemFormatString { System::String ^ get(); void set(System::String ^ value); };
public string StaticItemFormatString { get; set; }
member this.StaticItemFormatString : string with get, set
Public Property StaticItemFormatString As String

屬性值

與所有功能表項目一起顯示的其他文字或字元。 此屬性的預設值為 「 {0} 」。

範例

下列程式碼範例示範如何使用 StaticItemFormatStringDynamicItemFormatString 屬性,將文字新增至每個功能表項目。


<%@ 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 StaticItemFormatString and DynamicItemFormatString Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu StaticItemFormatString and DynamicItemFormatString Example</h3>
    
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="1"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server"
        StaticItemFormatString="To Go to: {0}"
        DynamicItemFormatString="Click here: {0}">
        
        <dynamicmenustyle backcolor="LightSkyBlue"
          forecolor="Black"
          borderstyle="Solid"
          borderwidth="1"
          bordercolor="Black" />
      
        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Home"
            tooltip="Home"
              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="Movies"
              tooltip="Movies"
              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="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 StaticItemFormatString and DynamicItemFormatString Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu StaticItemFormatString and DynamicItemFormatString Example</h3>
    
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="1"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server"
        StaticItemFormatString="To Go to: {0}"
        DynamicItemFormatString="Click here: {0}">
        
        <dynamicmenustyle backcolor="LightSkyBlue"
          forecolor="Black"
          borderstyle="Solid"
          borderwidth="1"
          bordercolor="Black" />
      
        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Home"
            tooltip="Home"
              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="Movies"
              tooltip="Movies"
              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>

備註

這個屬性可用來插入文字來格式化功能表中的靜態功能表項目。 這對行動裝置特別有用。 控制項 Menu 支援顯示靜態和動態功能表項目的範本,但會在行動裝置上忽略範本。 此屬性可讓您新增字元或文字,並在不使用範本的情況下,將格式套用至行動裝置和桌面裝置的功能表項目。

注意

若要在使用此屬性時達到一致的格式設定,如果您想要在靜態和動態功能表項目之間設定格式設定相同,也應該設定 DynamicItemFormatString 屬性。

如果同時套用範本格式設定和此屬性,則會忽略行動裝置的範本格式設定。

適用於

另請參閱