MenuItemBinding.ToolTipField 属性

定义

获取或设置数据源中字段的名称,该字段将绑定到 ToolTip 对象将应用到的 MenuItem 对象的 MenuItemBinding 属性。Gets or sets the name of the field from the data source to bind to the ToolTip property of a MenuItem object to which the MenuItemBinding object is applied.

public:
 property System::String ^ ToolTipField { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string ToolTipField { get; set; }
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string ToolTipField { get; set; }
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.ToolTipField : string with get, set
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.ToolTipField : string with get, set
Public Property ToolTipField As String

属性值

String

绑定到应用 ToolTipMenuItemMenuItemBinding 的字段的名称。The name of the field to bind to the ToolTip of a MenuItem to which the MenuItemBinding is applied. 默认值为空字符串 (""),表示尚未设置此属性。The default is an empty string (""), which indicates that this property is not set.

属性

示例

下面的代码示例演示如何使用 ToolTipField 属性指定要绑定到菜单项的属性的字段名称 ToolTipThe following code example demonstrates how to use the ToolTipField property to specify the name of the field to bind to the ToolTip property of a menu item. 要使此示例正常工作,必须将下面的示例 XML 数据复制到名为 Menu.xml 的文件中。For this example to work correctly, you must copy the sample XML data below to a file named Menu.xml.


<%@ 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>MenuItemBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>MenuItemBinding Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <DataBindings>
        
          <asp:menuitembinding datamember="MapHomeNode"
            formatstring="({0})" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding datamember="MapNode" 
            depth="1"
            formatstring="[{0}]" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding datamember="MapNode" 
            depth="2"
            formatstring="<{0}>" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </DataBindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="Menu.xml"
        runat="server"/> 

    </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>MenuItemBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>MenuItemBinding Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <DataBindings>
        
          <asp:menuitembinding datamember="MapHomeNode"
            formatstring="({0})" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding datamember="MapNode" 
            depth="1"
            formatstring="[{0}]" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding datamember="MapNode" 
            depth="2"
            formatstring="<{0}>" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </DataBindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="Menu.xml"
        runat="server"/> 

    </form>
  </body>
</html>

下面的代码是上一示例的示例站点地图数据。The following code is sample site map data for the previous example.

<MapHomeNode ImageUrl="~\Images\Home.gif"

Title="Home"

Description="Root Page"

ToolTip="Home Page">

<MapNode ImageUrl="~\Images\Music.gif"

Title="Music"

Description="Music Category"

ToolTip="Music Page">

<MapNode ImageUrl="~\Images\Classical.gif"

Title="Classical"

Description="Classical Section"

ToolTip="Classical Page"/>

<MapNode ImageUrl="~\Images\Rock.gif"

Title="Rock"

Description="Rock Section"

ToolTip="Rock Page"/>

<MapNode ImageUrl="~\Images\Jazz.gif"

Title="Jazz"

Description="Jazz Section"

ToolTip="Jazz Page"/>

</MapNode>

<MapNode ImageUrl="~\Images\Movies.gif"

Title="Movies"

Description="Movies Category"

ToolTip="Movies Page">

<MapNode ImageUrl="~\Images\Action.gif"

Title="Action"

Description="Action Section"

ToolTip="Action Page"/>

<MapNode ImageUrl="~\Images\Drama.gif"

Title="Drama"

Description="Drama Section"

ToolTip="Drama Page"/>

<MapNode ImageUrl="~\Images\Musical.gif"

Title="Musical"

Description="Musical Section"

ToolTip="Musical Page"/>

</MapNode>

</MapHomeNode>

注解

Menu 控件绑定到数据源时,请使用 ToolTipField 属性指定要绑定到对象的属性的字段名称 ToolTip MenuItemWhen the Menu control is bound to a data source, use the ToolTipField property to specify the name of the field to bind to the ToolTip property of a MenuItem object. 呈现时, ToolTip 应用对象的每个菜单项的属性 MenuItemBinding 包含字段中的相应值。When rendered, the ToolTip property of each menu item to which the MenuItemBinding object is applied contains the corresponding value from the field. 当用户将鼠标指针放在菜单项上时,将显示指定的文本。The specified text is displayed when the user positions the mouse pointer over a menu item.

备注

您可以通过直接设置菜单项的属性来覆盖单个菜单项的文本 ToolTipYou can override the text for an individual menu item by setting its ToolTip property directly.

如果数据源包含多个表或属性,则必须先通过设置 Depth 属性和/或属性来建立绑定条件 DataMemberIf the data source contains multiple tables or attributes, you must first establish the binding criteria by setting the Depth property, the DataMember property, or both.

ToolTip MenuItem 您还可以通过设置属性将对象的属性绑定到静态值,而不是使用此属性将对象的属性绑定到字段 MenuItemBinding.ToolTipInstead of using this property to bind the ToolTip property of a MenuItem object to a field, you can also bind it to a static value by setting the MenuItemBinding.ToolTip property. 这使您可以为应用对象的每个菜单项显示相同的工具提示 MenuItemBindingThis allows you to display the same ToolTip for each menu item to which the MenuItemBinding object is applied.

备注

如果 ToolTip ToolTipField 同时设置了和属性,则 ToolTipField 属性优先。If the ToolTip and ToolTipField properties are both set, the ToolTipField property takes precedence.

适用于

另请参阅