ASP.NET Custom Server Controls: Cute ToolTip Control with Better Framework
(Page 1 of 6 )
This article further extends my previous article on “Cute ToolTip control” with a few more enhancements, together with a flexible and understandable approach to the JavaScript code.
A downloadable file for this article 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.
How is it different from the old one?
I already introduced a technique for creating our own “tooltip” control for our web application. Even though it works well for that scenario, certain features are still missing. Let us consider what would happen if I wanted to add a HTML table within the tool tip. By using the method I discussed in my previous article, it is highly complicated. I actually designed that “tooltip” control simply to display some messages (and it works well only for that scenario).
But one of my colleagues asked me to improve it a bit, so that it would accept any HTML based content (because it is very easy to work with HTML, rather than with DHTML)! I liked his suggestion and started designing a flexible JavaScript framework (which is the main problem with my previous control) to achieve his expectations.
Finally, I came up with a solution by separating JavaScript content (from the custom control) to an external file (.js). This would cause the browser to cache the JavaScript file in memory, and we can even achieve better performance. Apart from simply writing structured JavaScript code, now I managed to redesign the JavaScript with some object orientation.
As you know, JavaScript is not a complete Object Oriented Programming language (actually it is an Object Based Language), so it is a bit difficult to abstract and encapsulate all the issues. But, somehow I managed to get it a bit encapsulated. As there is always room for new innovations (or enhancements), I hope that you would modify and extend the same control according to your necessities. Don’t forget to email me with your better enhancements.
Coming to the details of the “cute tool tip control” class, I am emitting only IFRAME tags and very little JavaScript code. I separated the whole burden of JavaScript code to a separate file (.js). But now you have to carry (of course even copy) the same file to every web application, which needs the tool tip functionality, unless you make an alternate arrangement by configuring your IIS to work for all web applications (from the same host).
Now that we understand some enhancements to my previous “Cute Tooltip control”, we shall delve into the details of code.
Next: What are the properties declared and how do I work with the control? >>
More ASP.NET Articles
More By Jagadish Chaterjee