CallBack vs. UpdatePanel?

Posted Thu Jan 25, 2007 @ 12:51 PM

With the growing proliferation of Microsoft's ASP.NET AJAX, we are often asked by customers whether our CallBack control is intended as a replacement for UpdatePanel, or alternatively, whether UpdatePanel makes the CallBack control obsolete. To address these questions, I feel I should try to clear things up a bit.

CallBacks are simply different from UpdatePanels, and the two are not pitted against each other in any way (hence the question mark in the title of this entry). They are simply two different tools in the AJAX toolbox, if you will. The CallBack control can be thought of as a simpler, more light-weight tool.

UpdatePanels post the whole page, effectively performing a postback with each request. They do so asynchronously, so the original page stays put. The control then figures out which updateable areas of the page are affected by that postback (areas in UpdatePanels, essentially), and it redraws those areas, and updates ViewState. This mechanism preserves the old postback-based ASP.NET paradigm.

CallBack uses a different paradigm, simply letting you render some markup into a container, without posting the state of other controls (unless you want to). The rendering is not done via the usual ASP.NET mechanism, but through a server-side event handler, which determines exactly what gets sent back. Nothing else on the page can get modified, and ViewState is left untouched.

Long story short, you might want to use CallBacks for simple scenarios where all you want to do is write some stuff from the server onto the client based on a simple parameter. Also, by using CallBacks, you're not requiring the inclusion of the ASP.NET AJAX library, further optimizing things. If you are designing an application from scratch and want to be able to retrieve server-side content with client-side APIs, CallBack is a great tool to look at.

For scenarios where the postback paradigm needs to be preserved (eg. there are inter-control dependencies, state of controls inside the panel needs to be maintained, usual asp.net rendering should be used, etc), UpdatePanels are recommended.
 
Though the controls seem to do the same thing, we actually see them as complementing each other. They impose different paradigms and allow for different architectures, and depending on what the developer needs to accomplish, one is usually more appropriate than the other.

More choice can only be a good thing, I think!

 

Comments

Artur

Posted on Thu Jan 25, 2007 @ 12:51 PM

Good Article. There are many confusion about update panel. Here, you explain one thing that i considere crucial: update panel always perform a full post back. sorry my english

sairam sadanala

Posted on Thu Jan 25, 2007 @ 12:51 PM

it is a good article in cutshort u cover all the things.thanks for giving this article and keep posting

Lorenzo

Posted on Thu Jan 25, 2007 @ 12:51 PM

It's possible have the upload control work with a updatepanel? Thanks

Posted on Thu Jan 25, 2007 @ 12:51 PM

The article below discusses something about update panel http://www.componentart.com/BLOGS/milos/archive

Click here to log in or create an account.