Geeks With Blogs


Aaron Li's Blog Write it down before I forget
What is the difference between a callback and a postback?
A callback is a special postback, so a round-trip always occurs; however, unlike the classic postback, the script callback doesn't redraw the whole page. ViewState is not updated during a callback, it is for postback.
How to make a callback?
In the client side JavaScript code, if GetCallbackEventReference() method is reference, then when the JavaScript code is executed, a channel to the server is opened and an HTTP request is sent to the remote ASP.NET page.
How does the ASP.NET runtime know this HTTP request is a Callback rather than a Postback?
After the ASP.NET runtime get a HTTP request, it looks for a __CALLBACKID entry in the Request collection. If such an entry is found, the runtime concludes that a callback invocation is being made.
GetCallbackEventReference() syntax
public string GetCallbackEventReference (
string target,      
    string argument,     
string clientCallback,      
    string context,
    string clientErrorCallback,
    bool useAsync
there are overloads such as
ClientScriptManager.GetCallbackEventReference (Control, String, String, String)
ClientScriptManager.GetCallbackEventReference (Control, String, String, String, Boolean)
GetCallbackEventReference() Parameters
The name of a server Control that handles the client callback. The control must implement the ICallbackEventHandler interface and provide a RaiseCallbackEvent method (which could be the page itself).
An argument passed from the client script to the server RaiseCallbackEvent method.
The name of the client event handler that receives the result of the successful server event.
Client script that is evaluated on the client prior to initiating the callback. The result of the script is passed back to the client event handler.
The name of the client event handler that receives the result when an error occurs in the server event handler.
true to perform the callback asynchronously; false to perform the callback synchronously.
Posted on Friday, April 20, 2007 2:02 AM | Back to top

Comments on this post: Script Callback

# re: Script Callback
Requesting Gravatar...
This page clearly explains the difference between postback and callback. Thanks a lot.
Left by Logeshwaran M on Sep 05, 2007 10:06 AM

# re: Script Callback
Requesting Gravatar...
pretty good!thank u.
Left by dongzz on Jun 06, 2009 10:10 PM

# re: Script Callback
Requesting Gravatar...
Simply Speaking we can say it's client end(callback) vs Server End(postback) aint it?
Left by Vicky Biswas on Nov 03, 2009 1:27 AM

# re: Script Callback
Requesting Gravatar...
First of all thanks for your article. But - "A callback is a special postback" doesn't tell me anything! I am exactly where I was before coming to this page. This is like MSDN help :p...
I need to know what is a callback with examples... thanks...
Left by Cold Fusion on Mar 24, 2010 10:35 AM

# re: Script Callback
Requesting Gravatar...
I'm chinese,your article is very good .but I want to know how to work about callback
Left by lixinnan on Jan 05, 2011 3:51 AM

# re: Script Callback
Requesting Gravatar...
this is where you can find the best answer:
Left by yousif on Apr 02, 2013 7:44 PM

Your comment:
 (will show your gravatar)

Copyright © Aaron Li | Powered by: | Join free