Sunday, May 23, 2010

You must see the 2 attached pictures to be admired with the difference

image image

Client-Side Callback

ASP.NET 2.0 includes a new client callback feature that enables you to retrieve page values and populate them to an already-generated page without regenerating the page. This makes it possible to change values on a page without going through the entire postback cycle; that means you can update your pages without completely redrawing the page. End users will not see the page flicker and reposition, and the pages will have a flow more like the flow of a thick-client application.

To work with the new callback capability, you have to know a little about working with JavaScript. This book does not attempt to teach you JavaScript. If you need to get up to speed on this rather large topic, check out Wrox's Beginning JavaScript, Second Edition, by Paul Wilton (ISBN: 0-7645-5587-1).

Comparing a Typical Postback to a Callback

Before you jump into some examples of the new callback feature, first look at a comparison to the current postback feature of a typical ASP.NET page.

When a page event is triggered on an ASP.NET page that is working with a typical postback scenario, a lot is going on. The diagram in Figure 4-13(see the "postback.gif" attached picture) illustrates the process.

In a normal postback situation, an event of some kind triggers an HTTP Post request to be sent to the Web server. An example of such an event might be the end user clicking a button on the form.

sends the HTTP Post request to the Web server, which then processes the request with the IPostbackEventHandler and runs the request through a series of page events. These events include loading the state (as found in the view state of the page), processing data, processing postback events, and finally rendering the page to be interpreted by the consuming browser once again.

The process completely
reloads the page in the browser, which is what causes the flicker and the realignment to the top

of the page.

On the other hand, you have the alternative of using the new callback capabilities, as shown in the diagram in Figure 4-14(see the "callback.jpg" attached picture).

In this case, an event (again, such as a button click) causes the event to be posted to a script event handler (a JavaScript function) that sends off an asynchronous request to the Web server for processing.

ICallbackEventHandler runs the request through a pipeline similar to what is used with the postback- but you notice that some of the larger steps (such as rendering the page) are excluded from the process chain. After the information is loaded, the result is returned to the script callback object.

The script code
then pushes this data into the Web page using JavaScript's capabilities to do this without refreshing the page. To understand how this all works, look at the simple example in the following section.

Next mail will contain the example

C# fast-food by:

Eng.Waleed abou-zaid

Senior Software Developer

Harf Information Technology

MCSD.Net,MCAD.Net,MCP,A+,N+ certified