In this article, we will walk through the implementation of a tooltip feature that displays both a date and a detailed description dynamically. This feature is implemented in a table where the tooltip appears when hovering over a specific element, showing the most recent progress along with the associated date. The tooltip content is fetched from a separate database table, and it adjusts dynamically as the user interacts with the table.
Overview
In this example, when the user hovers over an element within a table, a tooltip will appear. The tooltip will contain two key parts:
Date – This is displayed at the top right of the tooltip.
Description – Below the date, a detailed progress description from the database will be displayed.
We will achieve this using the following steps:
Bind the
LatestProgressdata to thetooltip.Split the progress data into
dateandtextcomponents.Adjust the tooltip position based on the mouse location.
HTML Structure for Table with Tooltip
In this section, the tooltip is applied to a table of contact information. Each row has a Status link, which contains a tooltip attribute (data-tooltip). The tooltip is displayed dynamically when the user hovers over the link.
<div class="table_str clear">
<div class="table-responsive">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td height="10px"></td>
</tr>
<tr>
<td id="tdmsg" runat="server" align="center" class="Nodata" colspan="2"></td>
</tr>
<tr>
<td height="20px"></td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td>
<asp:DataGrid ID="lead_grid" runat="server" AutoGenerateColumns="False" Width="100%" CellSpacing="0" GridLines="None"
OnItemDataBound="lead_grid_ItemDataBound" AllowPaging="True" PageSize="10" OnPageIndexChanged="NewPage" AlternatingItemStyle-BackColor="#FAFBFE">
<Columns>
<asp:TemplateColumn HeaderText="Status">
<HeaderStyle CssClass="GridHeadL br" />
<ItemStyle CssClass="GridDataL br bb" />
<ItemTemplate>
<a href="javascript:void(0);" onclick="openProgressPopup1('<%# Eval("srno") %>');"
<%# Eval("LatestProgress") == DBNull.Value || string.IsNullOrEmpty(Eval("LatestProgress").ToString())
? "" : "data-tooltip=\"" + HttpUtility.HtmlAttributeEncode(Eval("LatestProgress").ToString()) + "\"" %>
class="GridDataC status-tooltip">
<%# Eval("Status") %>
</a>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
<!-- Tooltip div -->
<div id="customTooltip"></div>
CSS for Tooltip Styling
We define the basic styling for the tooltip to make it visually appealing and to ensure that it behaves correctly when displayed near the mouse cursor.

Join the conversation! Your thoughts help the community grow.