Which property or method should i use to bind the ToolTip property to an ImageField Class?
-
15-04-2021 - |
Question
In an image control that is bound within a GridView column i can set the Alt text property by using the DataAlternateTextField
property.
<asp:ImageField DataImageUrlField="Flag"
DataImageUrlFormatString="~/images/f/{0}.png"
DataAlternateTextField="Description" >
</asp:ImageField>
which results in somathing like...
<img src="1.png" alt="Alt text"/>
Which property or method should i use to bind the ToolTip property?
<img src="1.png" alt="Alt text" ToolTip="Title text" />
I would like the users of the website, on mouse hovering of the image, to be able to read the title property.
Solution
You can use binding expression to set the title of the ImageField. http://msdn.microsoft.com/en-us/library/ms178366.aspx
OTHER TIPS
To all newbies out there just like me, here what i did
<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>
Thanks Veronica
I am playing with this issue now according to Microsoft, the alternate text property of an ImageField should translate into a tooltip as well. At least that's what it says on the msdn page i just linked.