ASP.NET tooltip alternative: Cool DHTML Tooltip II – Part 2

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.

2. Assign JavaScript events to the server control interested

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:

In VB.NET

imgQuestion.Attributes.Add(“onmouseover”, “ddrivetip(‘” & tooltipMessage & “’, 300);”)

imgQuestion.Attributes.Add(“oumouseout”, “hideddrivetip();”)

In C#

imgQuestion.Attribute.Add(“onmouseover”, “ddrivetip(‘” + tooltipMessage + “’, 300);”);

imgQuestion.Attribute.Add(“onmouseout”, “hideddrivetip();”);

And you are done!

Leave a Reply

avatar
  Subscribe  
Notify of