Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

ASP.NET Callback – and WHY?

5.00/5 (1 vote)
28 Jan 2013CPOL2 min read 10.1K  
ASP.NET callback issues.

If you are familiar with ASP.NET Web Form development, I think Postback and Callback are not new topics for you. Now, let me show the impact on traffic for each methods.

image

I prepared three ways to perform server request for this sample. Each of them represented by a button and they are “Postback”, “Callback” and “Update Panel” (Partial Postback).

For a better illustration, I use Fiddler to capture the traffic. And let's see what we have after click on each button.

  • Postback

image

For all the resources including javascript, embedded resources and web page (It can be more which including CSS files, images, media, external link… etc.) will be send to browser again even only one button begin clicked.

  • Callback

image

Not bad. Only web page being updated. With 1,192 bytes sent and 761 bytes received.

  • Update Panel

image

This one also not bad. Only web page being updated. With 1,319 bytes sent and 1,266 bytes received (As I only wrap one set of First Name, Last Name & Button controls in the Update Panel).

After this experiment, let me explain why the traffic is different for each different ways to reach server.

  • Postback

All contains of the web page (ViewState, Hidden Controls…etc.) will be send back to the server. During the browser process response of the request, it will request all resources again. Like Javascript files, Images, CSS files… .etc.

  • Callback

All contains of the web page (ViewState, Hidden Controls…etc.) will be send back to the server. Here I have to highlight one thing, ViewState objects do travel back to server but you are not able to modify any value of controls. This is because the page life cycle for Callback doesn’t include SaveViewState and Render events. For detail, you can refer to Brij Bhushan Mishra’s blog – Exploring Client Callback

  • Update Panel

All contains of the web page (ViewState, Hidden Controls…etc.) will be send back to the server. But what had been return in the response package is only content of the area that I put into the Update Panel Content Template. The page life cycle for this request is the same as Postback but just it will not refresh/update for the controls out of the Update Panel.

Summary

Postback: is the easiest way to program by using ASP.NET Web Form but It will make the traffic from server becomes heavy.

Callback: not easy to implement if compare among the other two. But it produce light traffic from server and return only what the request need.

Update Panel: not hard to implement but I suggest you to read Dave Ward’s blog – Why ASP.NET AJAX UpdatePanels are dangerous and have more understand on how it works before you consider to implement this.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)