In Part 1, I showed you how to use Cool DHTML Tooltip in ASP.NET web applications with static data. In this post, I will show you how to use Cool DHTML Tooltip with dynamic data pulled from database. It is actually very simple. Here are the steps:
1. Pull data from database.
In code-behind, you need to pull from your database the information that needs to be displayed in tooltip, format the information if needed, then save the string in a local variable, say called tooltipMessage.
For instance, if you want to display tooltip on an Image control called imgQuestion, then all you need to do is to add “onmouseover” and “onmouseout” to the control’s attributes collection:
imgQuestion.Attributes.Add(“onmouseover”, “ddrivetip(‘” & tooltipMessage & “’, 300);”)
imgQuestion.Attribute.Add(“onmouseover”, “ddrivetip(‘” + tooltipMessage + “’, 300);”);
And you are done!