One of the most attractive features that ASP.NET 2.0 has contributed
to the web development field is the script callback, which allows you to make a
server-side call from the client side without posting back to the server. In essence,
the client-side script callback utilizes the XmlHttp component implemented by
most of the up-to-date web browsers to set up communication with the server side.
The following Figure describes the rough mechanism of the client-side script
callback inside ASP.NET 2.0 architecture.
Figure 5: Mechanism of the ASP.NET 2.0 client-side
As depicted by the above figure, performing a client
callback involves the following steps:
1. Call the page's GetCallbackEventReference
method to get the name of a client-side function that will be called to
initiate a callback. (Note that the GetCallbackEventReference
method is declared in the ICallbackEventHandler namespace,
and thus your server-side controls must explicitly implement that interface ;
function is called from the client side.
2. That function prompts ASP.NET's callback manager, which
is itself implemented in client-side script, to launch an XMLHTTP callback to
3. On the server side, ASP.NET receives the call and invokes
the page's ICallbackEventHandler.RaiseCallbackEvent()
method, which processes and returns the callback.
4. The callback manager is notified that the execution has
5. The callback manager notifies the caller that the call was
completed by calling a client-side notification function (provided by the
caller when it initiated the call).
In the next section, we are to create a sample to demonstrate
ASP.NET 2.0's script callback feature, by which we are also to achieve in
partially updating a web page.