Off course that is in some of the cases and not all of them. AJAX is a very beautifull framework and has some great possibilities. Sometimes however a simple lightweighted callback is all that's needed to perform a simple task. (Read #9 over here). It is, no let me rephrase that, it WAS not the easiest task to implement such a lightweighted callback however. That's where this new CallbackController control comes around the corner. First outline the challenge I was facing.
Right now I'm in the middle of a technical design for a big, interactive Sharepoint 2007 Portal. The problem I encountered though is not very Sharepoint specific. I needed to change control #1 on a specific client event of control #2. Let me explain this a little further. We have a slideshow control that shows images about a region, but as soon as a customer hovers a region on an imagemap, the slideshow must show different images. We have a Google Maps control, and as soon as a client hovers on a specific menu item, the Google maps control needs to show some different pointers. Both the images and pointers however come from a database(in this case a SPList).
ASP.Net 2.0 comes with callbacks and the ICallbackEventHandler interface and if you look around on the internet you'll find a lot of examples of how to implement the interface on a Page. Nice BUT AGAIN in Sharepoint we work with webparts containing controls and we can't implement interfaces on the page. So that won't work for us. We'll need to implement the interface on a control. With the Callback system we CAN get a GetCallbackEventReference to a control method! So I outlined a few requirements.
As always I have a lot of code here for you guys. The complete source and a sample web using the CallbackController is included in the download. This is just V0.1 and it's written as a proof of concept for my technical design but it does it's job pretty well so far.
And a page declaration:
It's now very simple to add callbacks to your page! I do not have the time to explain all details of the code. Simply download the solution and have a look at it. If you do have any questions, please feel free to ask.