【问题标题】:Which property or method should i use to bind the ToolTip property to an ImageField Class?我应该使用哪个属性或方法将 ToolTip 属性绑定到 ImageField 类?
【发布时间】:2012-02-05 12:08:54
【问题描述】:

在绑定在 GridView 列中的图像控件中,我可以使用 DataAlternateTextField 属性设置 Alt 文本属性。

<asp:ImageField DataImageUrlField="Flag" 
     DataImageUrlFormatString="~/images/f/{0}.png"
     DataAlternateTextField="Description"  >
</asp:ImageField>

这会导致...

<img src="1.png" alt="Alt text"/>

我应该使用哪个属性或方法来绑定 ToolTip 属性?

<img src="1.png" alt="Alt text"  ToolTip="Title text" />

我希望网站的用户在鼠标悬停图像时能够阅读标题属性。

【问题讨论】:

    标签: asp.net .net data-binding gridview imagefield


    【解决方案1】:

    根据Microsoft,我现在正在处理这个问题,ImageField 的替代文本属性也应该转换为工具提示。至少我刚刚链接的 msdn 页面上是这样说的。

    【讨论】:

      【解决方案2】:

      对于所有像我一样的新手,这是我所做的

                   <asp:TemplateField HeaderText="Test" SortExpression="">
                       <ItemTemplate>
                       <asp:Image ID="Image1" runat="server" 
                          ImageUrl='<%# Eval("Flag", "~/images/f/{0}.png") %>' 
                          AlternateText='<%# Bind("Description") %>' 
                          ToolTip='<%# Bind("Description") %>' />
                       </ItemTemplate>
                    </asp:TemplateField>
      

      谢谢维罗妮卡

      【讨论】:

        【解决方案3】:

        您可以使用绑定表达式来设置 ImageField 的标题。 http://msdn.microsoft.com/en-us/library/ms178366.aspx

        【讨论】:

        • 这意味着我必须先将图像转换为ItemTemplate?
        • 是的,如果它是 GridView 或我认为的其他控件的一部分:)
        猜你喜欢
        • 2018-04-04
        • 2012-06-10
        • 2013-05-04
        • 1970-01-01
        • 1970-01-01
        • 2016-04-30
        • 1970-01-01
        • 1970-01-01
        • 2014-08-04
        相关资源
        最近更新 更多