Menu.StaticItemFormatString 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會接收或設定所有靜態顯示的選單項目中顯示的額外文字。
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}.」。
範例
以下程式碼範例示範如何使用 StaticItemFormatString 和 DynamicItemFormatString 屬性為每個選單項目添加文字。
<%@ 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 屬性。
若同時套用範本格式與此屬性,則該範本格式在行動裝置上會被忽略。