Chapter 4. Understanding the ASP.NET AJAX Client Library

It is true that many of the application improvements that result from using AJAX occur because you are doing more in the JavaScript language in the browser. This does include the asynchronous communications with the server, preloading images and data, manipulation of the browser DOM, and more. What these improvements in the model all have in common is an increased use of JavaScript on your pages is needed to accomplish these tasks.

ASP.NET AJAX, as built into ASP.NET 3.5, provides some key features that make including and working with JavaScript easier overall. By employing some similar patterns, Microsoft has really gone the extra mile in making working with JavaScript feel similar to working with C# and Visual Basic. This chapter looks at the type system provided by the Microsoft AJAX Library that makes it easier to employ familiar OOP (object-oriented programming) patterns in your JavaScript development. This chapter also reviews a set of JavaScript classes that provide core functionality similar to the base class libraries found in the .NET Framework.

The AJAX Library brings concepts from the .NET Framework to JavaScript running in the browser, making the server and client coding models a bit more consistent. However, because JavaScript is inherently quite different from C# or Visual Basic, and because you cannot leverage the .NET Framework on the user's computer, you should not expect a high degree of compatibility and consistency here. The AJAX Library has also added a client-side page lifecycle, similar in concept to the ASP.NET server-side page lifecycle. This addition makes it easy to participate in the processing of the page, work with partial page rendering, and provide event handlers for user actions.

It is important to point out here that with ASP.NET AJAX, you get many of the application advantages without writing a lot of JavaScript yourself. In Chapter 2, for example, you saw how to use server controls that automatically generate JavaScript for you to enable partial page rendering. In Chapter 6 of this book, you will see a set of controls from the AJAX Control Toolkit that provide some interesting UI features that leverage the Microsoft AJAX Library and do not require you to write a lot of JavaScript. Microsoft has done a great deal of work for you. When you want to write your own controls, add custom event handlers, or start doing more in the browser, however, you will likely need to write custom JavaScript code. The ASP.NET AJAX Client Library and some recommended coding patterns make you more productive in that work.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset