Menu.StaticItemFormatString 属性
定义
获取或设置与所有静态显示的菜单项一起显示的附加文本。Gets or sets additional text shown with all menu items that are statically displayed.
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
属性值
与所有菜单项一起显示的附加文本或字符。The additional text or characters that appear with all menu items. 此属性的默认值为 " {0} ."。The default value for this property is "{0}."
示例
下面的代码示例演示如何使用 StaticItemFormatString 和 DynamicItemFormatString 属性将文本添加到每个菜单项。The following code example demonstrates how to use the StaticItemFormatString and DynamicItemFormatString properties to add text to each menu item.
<%@ 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>
注解
此属性可用于插入文本,以便设置菜单中静态菜单项的格式。This property can be used to insert text to format static menu items in a menu. 这对于移动设备特别有用。This is particularly useful for mobile devices. Menu控件支持用于显示静态和动态菜单项的模板,但在移动设备上忽略模板。The Menu control supports templates for the display of static and dynamic menu items, but templates are ignored on mobile devices. 此属性允许你添加字符或文本,并为移动设备和桌面设备的菜单项应用格式设置,而无需使用模板。This property allows you to add characters or text and to apply formatting to menu items for both mobile and desktop devices without using a template.
备注
若要在使用此属性时实现一致的格式设置, DynamicItemFormatString 如果要使静态菜单项和动态菜单项之间的格式相同,还应该设置属性。To achieve consistent formatting when you use this property, you should also set the DynamicItemFormatString property if you want the formatting to be identical between the static and dynamic menu items.
如果同时应用了模板格式设置和此属性,则将忽略移动设备的模板格式设置。If both template formatting and this property are applied, the template formatting is ignored for mobile devices.