ASP.NET Custom Server Controls: Cute ToolTip Control
(Page 1 of 5 )
This article introduces you to creating a customized “ToolTip” control for your use in ASP.NET web applications.
A downloadable file for this application is available
here.
The sample downloadable solution (zip) is entirely developed using Visual Studio.NET 2003 Enterprise Architect on Windows Server 2003 Standard Edition. But, I am confident that it would work with other versions of Windows (which support .NET 1.1) as well.
What sort of “tooltip” is this?
This is the main question for which everyone wants the answer. Everyone knows that tooltips are essential for showing brief “help” for a particular task (or link). If it is a desktop application (not a web application) we can expose the tool tip's functionality very easily. Even HTML provides some of the tool tip's functionality for web pages (using the “alt” attribute). But it is not very customizable. For example, I might like to change the background color or foreground color of the tool tip; that is impossible.
Considering all of the above scenarios, I decided to design and create my own tooltip control for my web applications. At the beginning, I thought that it would be very easy to implement (by simply working with “DIV” tag). But there exists a problem with those tool tips, because they will always be behind “windowed” controls (like dropdown lists) on the web page. Finally I became mad when I found out the solution. After searching with Google, I found this solution: my tooltip needs to be equipped with an IFRAME (for Internet explorer only) tag.
When any content is written to IFRAME, the content always stays ahead of any other control (including windowed controls) on the web page (be careful to provide the proper z-index accordingly). But, we should always make sure that the “z-index” value is always higher than any other control on the web page. Some of the custom control designers would always give a z-index value of something like “99999”, thinking that there will not be 100,000 controls on a single page. They are correct. No web page would ever contain 100,000 controls! I am also trying to implement the same type of trick in my control.
But there is one drawback. Not every browser supports IFRAME! Consider Netscape; it could not support IFRAME (but supports LAYER in place of it). As this article mainly focuses on IFRAME, it would only work for Internet Explorer. But you can enhance this control according to your requirement for cross-browser independence (as I am enclosing full source code as part of a download).
And another issue is that, I am not simply confirming that this is the only way (or method) to support tooltips in web applications. This article only gives you an idea of how to start and get working with IFRAMEs in ASP.NET web applications (supporting Internet Explorer) as part of server controls. I suggest that you enhance the same according to your requirements and all the flavors necessary.
So, let us start into the details of “tooltip” control.
Next: What are the properties declared and how do we work with the control? >>
More ASP.NET Articles
More By Jagadish Chaterjee