MenuItemBinding.Text プロパティ
アセンブリ: System.Web (system.web.dll 内)

[LocalizableAttribute(true)] public: property String^ Text { String^ get (); void set (String^ value); }
MenuItemBinding が適用されるメニュー項目に表示されるテキスト。既定値は空の文字列 ("") です。この値は、このプロパティが設定されていないことを示します。

Menu コントロールをデータ ソースにバインドする場合、MenuItem オブジェクトの MenuItem.Text プロパティにバインドするテキストは、Text プロパティで指定します。このテキストはメニュー項目に表示され、MenuItemBinding オブジェクトが適用されるすべてのメニュー項目で共有されます。
![]() |
---|
このプロパティを使用して各メニュー項目に同じテキストを表示する代わりに、TextField プロパティを設定して、MenuItem オブジェクトの Text プロパティをデータ ソースのフィールドにバインドすることもできます。レンダリング時、MenuItemBinding オブジェクトを適用した各メニュー項目の Text プロパティには、そのフィールドの対応する値が格納されます。
Text プロパティや TextField プロパティを空の文字列 ("") に設定しても、Menu コントロール内に空のノードを作成することはできません。これらのプロパティを空の文字列に設定した場合、プロパティを設定しないことと同じです。この場合、Menu コントロールは、DataSource プロパティを使用して既定のバインディングを作成します。詳細については、「Web ページのデータ バインド技術」を参照してください。
このプロパティを設定している場合、デザイナ ツールを使用して、その値を自動的にリソース ファイルに保存できます。詳細については、LocalizableAttribute、ASP.NET のグローバリゼーションおよびローカリゼーション の各トピックを参照してください。

Text プロパティを使用して、メニュー項目に表示するテキストを指定する方法を次のコード例に示します。このテキストは、MenuItemBinding オブジェクトが適用される各メニュー項目に表示されます。この例を正常に動作させるには、以下のサンプル XML データを、Menu.xml という名前のファイルにコピーする必要があります。
<%@ page language="VB" %> <html> <body> <form runat="server"> <h3>MenuItemBinding Example</h3> <asp:menu id="NavigationMenu" datasourceid="MenuSource" runat="server"> <databindings> <asp:menuitembinding datamember="MapHomeNode" textfield="Title" valuefield="Description" imageurlfield="ImageUrl" tooltipfield="ToolTip"/> <asp:menuitembinding datamember="MapNode" depth="1" textfield="Title" valuefield="Description" imageurlfield="ImageUrl" tooltipfield="ToolTip"/> <asp:menuitembinding datamember="MapNode" depth="2" text="Static Title" value="Static Description" imageurl="~\Images\StaticImage.jpg" tooltip="Static ToolTip"/> </databindings> </asp:menu> <asp:xmldatasource id="MenuSource" datafile="Menu.xml" runat="server"/> </form> </body> </html>
<%@ page language="C#" %> <html> <body> <form runat="server"> <h3>MenuItemBinding Example</h3> <asp:menu id="NavigationMenu" datasourceid="MenuSource" runat="server"> <databindings> <asp:menuitembinding datamember="MapHomeNode" textfield="Title" valuefield="Description" imageurlfield="ImageUrl" tooltipfield="ToolTip"/> <asp:menuitembinding datamember="MapNode" depth="1" textfield="Title" valuefield="Description" imageurlfield="ImageUrl" tooltipfield="ToolTip"/> <asp:menuitembinding datamember="MapNode" depth="2" text="Static Title" value="Static Description" imageurl="~\Images\StaticImage.jpg" tooltip="Static ToolTip"/> </databindings> </asp:menu> <asp:xmldatasource id="MenuSource" datafile="Menu.xml" runat="server"/> </form> </body> </html>
前の例のサンプル サイト マップ データを次のコードに示します。
<MapHomeNode ImageUrl="~\Images\Home.gif"
<MapNode ImageUrl="~\Images\Music.gif"
<MapNode ImageUrl="~\Images\Classical.gif"
Description="Classical Section"
<MapNode ImageUrl="~\Images\Rock.gif"
<MapNode ImageUrl="~\Images\Jazz.gif"
</MapNode>
<MapNode ImageUrl="~\Images\Movies.gif"
<MapNode ImageUrl="~\Images\Action.gif"
<MapNode ImageUrl="~\Images\Drama.gif"
<MapNode ImageUrl="~\Images\Musical.gif"
</MapNode>
</MapHomeNode>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItemBinding クラス
MenuItemBinding メンバ
System.Web.UI.WebControls 名前空間
Menu クラス
MenuItem クラス
MenuItemBindingCollection
XmlDataSource
Menu.DataBindings プロパティ
MenuItemBinding.DataMember プロパティ
MenuItemBinding.Depth プロパティ
MenuItemBinding.FormatString プロパティ
MenuItemBinding.ImageUrl プロパティ
MenuItemBinding.ImageUrlField プロパティ
MenuItemBinding.NavigateUrl プロパティ
MenuItemBinding.NavigateUrlField プロパティ
MenuItemBinding.Target プロパティ
MenuItemBinding.Text プロパティ
TextField
ToolTip
ToolTipField
Value
ValueField
Weblioに収録されているすべての辞書からMenuItemBinding.Text プロパティを検索する場合は、下記のリンクをクリックしてください。

- MenuItemBinding.Text プロパティのページへのリンク