Chapter 22. Ajax Programming

Users want Web applications that are as interactive as Windows applications are. Asynchronous JavaScript and XML—Ajax—is a technology that makes it easy to create interactive Web applications.

In this chapter, you

  • Get an overview of Ajax.

  • Use the ASP.NET UpdatePanel control.

  • Use the ASP.NET AJAX Timer control.

  • Use the UpdateProgress control.

  • Create a Web service and call it from client script.

  • Explore the extender controls that you get in the ASP.NET AJAX Control Toolkit.

Ajax Overview

ASP.NET is based on postbacks. When the user clicks a button or makes a selection in a list box that has AutoPostBack enabled, a request is sent to the server, and the complete page is sent back to the client. For the user this doesn't give the feeling of a "normal" application, because the complete page is redrawn. The user interface should stay active on the client, and only additional data to display should be requested from the server.

In reality, the technology that Ajax is based on is not new. With Internet Explorer and Web applications this has been possible for many years. Internet Explorer has included the XmlHttpRequest object from version 5; this object makes it possible to send a request from within JavaScript while the page remains active. This was used in Outlook Web Access 2000 to give the user a better interactive experience. The problem with this technology was that it wasn't easy to use.

Ajax makes it easy to use the XmlHttpRequest object, and nowadays this feature ...

Get Beginning Microsoft® Visual C#® 2008 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.