MenuItem.Text 屬性
定義
public:
property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public string Text { get; set; }
member this.Text : string with get, set
Public Property Text As String
屬性值
針對 Menu 控制項中的功能表項目所顯示之文字。The text displayed for the menu item in the Menu control. 預設為空字串 ("")。The default is an empty string ("").
範例
下列範例示範如何使用 Text 屬性來指定要顯示在控制項中每個功能表項目的文字 Menu 。The following example demonstrates how to use the Text property to specify the text to display in each menu item in a Menu control.
<%@ 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>MenuItem Declarative Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>MenuItem Declarative Example</h3>
<!-- Use declarative syntax to create the -->
<!-- menu structure. Create submenu items -->
<!-- by nesting them within parent menu -->
<!-- items. -->
<asp:menu id="NavigationMenu"
staticdisplaylevels="1"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
imageurl="Images\Home.gif"
popoutimageurl="Images\Popout.jpg"
tooltip="Home">
<asp:menuitem navigateurl="Music.aspx"
text="Music"
popoutimageurl="Images\Popout.jpg"
tooltip="Music">
<asp:menuitem navigateurl="Classical.aspx"
text="Classical"
separatorimageurl="Images\Separator.jpg"
tooltip="Classical"/>
<asp:menuitem navigateurl="Rock.aspx"
text="Rock"
separatorimageurl="Images\Separator.jpg"
tooltip="Rock"/>
<asp:menuitem navigateurl="Jazz.aspx"
text="Jazz"
separatorimageurl="Images\Separator.jpg"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem navigateurl="Movies.aspx"
text="Movies"
popoutimageurl="Images\Popout.jpg"
tooltip="Movies">
<asp:menuitem navigateurl="Action.aspx"
text="Action"
separatorimageurl="Images\Separator.jpg"
tooltip="Action"/>
<asp:menuitem navigateurl="Drama.aspx"
text="Drama"
separatorimageurl="Images\Separator.jpg"
tooltip="Drama"/>
<asp:menuitem navigateurl="Musical.aspx"
text="Musical"
separatorimageurl="Images\Separator.jpg"
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>MenuItem Declarative Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>MenuItem Declarative Example</h3>
<!-- Use declarative syntax to create the -->
<!-- menu structure. Create submenu items -->
<!-- by nesting them within parent menu -->
<!-- items. -->
<asp:menu id="NavigationMenu"
staticdisplaylevels="1"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
imageurl="Images\Home.gif"
popoutimageurl="Images\Popout.jpg"
tooltip="Home">
<asp:menuitem navigateurl="Music.aspx"
text="Music"
popoutimageurl="Images\Popout.jpg"
tooltip="Music">
<asp:menuitem navigateurl="Classical.aspx"
text="Classical"
separatorimageurl="Images\Separator.jpg"
tooltip="Classical"/>
<asp:menuitem navigateurl="Rock.aspx"
text="Rock"
separatorimageurl="Images\Separator.jpg"
tooltip="Rock"/>
<asp:menuitem navigateurl="Jazz.aspx"
text="Jazz"
separatorimageurl="Images\Separator.jpg"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem navigateurl="Movies.aspx"
text="Movies"
popoutimageurl="Images\Popout.jpg"
tooltip="Movies">
<asp:menuitem navigateurl="Action.aspx"
text="Action"
separatorimageurl="Images\Separator.jpg"
tooltip="Action"/>
<asp:menuitem navigateurl="Drama.aspx"
text="Drama"
separatorimageurl="Images\Separator.jpg"
tooltip="Drama"/>
<asp:menuitem navigateurl="Musical.aspx"
text="Musical"
separatorimageurl="Images\Separator.jpg"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</form>
</body>
</html>
備註
您 Text 可以使用屬性來指定或判斷控制項中的功能表項目所顯示的文字 Menu 。Use the Text property to specify or determine the text that is displayed for the menu item in the Menu control.
注意
如果 Text 屬性包含,存取子會傳回 null
屬性的 get
值 Value 。If the Text property contains null
, the get
accessor returns the value of the Value property. 如果傳回,則 Value 會傳回包含的 null
屬性 Empty 。If the Value property, in turn, contains null
, Empty is returned.
設定時,可以使用設計工具將這個屬性的值自動儲存到資源檔。The value of this property, when set, can be saved automatically to a resource file by using a designer tool. 如需詳細資訊,請參閱 LocalizableAttribute 和 全球化和當地語系化。For more information, see LocalizableAttribute and Globalization and Localization.