In the previous part I talked about how to build the client control. In this part I'll show how to put it all together to build an ASP.NET AJAX Enabled Server Control. You can view the demo that demonstrate control usage here.
The good thing about ASP.NET AJAX is that it supports fully programmable interface for both Server and Client control. And make a connection between both control. So you just need to put the control declaration on the ASPX page and ASP.NET will make it work for you. On the other hand, you have full access to the client APIs so that you can do some manual calls to the client APIs as well.
Building the Server Control:
This is an ASP.NET AJAX Extender control. Means it extends existing ASP.NET control to enable ASP.NET AJAX on it. In this case this extender extends ASP.NET Panel control, that is why it is called CollapsiblePanelExtender. Here is an article to show you in details How To build Extender Controls.
Basically jQueryCollapsiblePanelExtender I am building here inherits directly from ExtenderControl. This required to implement 2 methods GetScriptDescriptors and GetScriptReferences which I am going to explore later. But now, I want to take your attention that I am using jQuery, and I wanted the developer to have the option to specify the path of the jQuery library. If he/she did not specify the path, the default path is used, which is the the one hosted by google at http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js. To do that I made a property and Call jQueryScriptPath that gets and sets jQuery javascript library path.
More...