As I’m writing this editorial Microsoft has just released ASP.NET AJAX 1.0 (MS AJAX). The journey for this product began back in the middle of 2005 and MS AJAX has just gone through a typical 18-month Microsoft product release cycle. Now that MS AJAX is here you can look forward to using it in your applications as an officially supported Microsoft product.

For most of you, MS AJAX is probably not news any longer, since we’ve all been hearing about the functionality and features for a year and a half now through the many preview releases. Anticipation for the final 1.0 product is quite high and many developers are already actively using the tools and getting ready to put them into production.

What’s in the 1.0 Release?

A few months ago when Microsoft moved from the ATLAS (Microsoft AJAX’s codename) previews into a beta release cycle, Microsoft decided to split the ASP.NET AJAX libraries into two separately distributed components. Microsoft released the ASP.NET AJAX 1.0 as an RTM version, which becomes a fully supported Microsoft product. Microsoft also has the ASP.NET 2.0 AJAX Futures CTP release that continues on the path of frequent changes and updates. The Futures release could introduce breaking changes in the future. Eventually Microsoft will integrate the Futures release into the ASP.NET Framework as part of the next version of the .NET Framework and Visual Studio. In addition to the ASP.NET AJAX libraries, there’s also the ASP.NET AJAX Control Toolkit, which provides a large number of controls built using the base ASP.NET AJAX 1.0 library. The ASP.NET AJAX Control Toolkit is a collaborative effort between Microsoft and the developer community to provide components and enhancements. Let me tell you what each of these components provides.

ASP.NET AJAX 1.0: Platform First

The ASP.NET AJAX 1.0 RTM release provides the core AJAX component for the Microsoft AJAX platform. It’s an add-in install for ASP.NET 2.0, which means that it doesn’t replace any of the original ASP.NET 2.0 bits, but rather installs as a completely separate component. You must install the RTM release into the GAC and you’ll have to make a number of configuration settings in web.config in order to run it as part of an existing application. New Visual Studio wizards provide Web project templates for projects that include MS AJAX functionality.

This hands-off approach means there are no service packs or other changes required for ASP.NET or the .NET Framework, but just a new install of this library. Microsoft made this approach a goal of this 1.0 release, which means the ASP.NET team had to make some tough design decisions to provide backwards compatibility without touching the existing ASP.NET codebase.

The ASP.NET AJAX 1.0 component is the baseline AJAX engine that provides the infrastructure required to build additional components on top of. On its own, the library provides the popular UpdatePanel-a powerful client script base library that provides many useful extensions and .NET-isms to the JavaScript language and network services that simplify making callbacks to the server and the current page.

UpdatePanel

The UpdatePanel server control-the most popular control of the library-makes it easy to create pages that have partially updating content. You simply drop the UpdatePanel server control on a page and wrap it around any block of markup and controls. You can then trigger the panel by either causing a server event from a control inside the panel, or by assigning external event triggers. The AJAX callback fires to the server and updates only the content of the panel. This control provides a no-code approach to AJAX and because of that, many developers have made it a favorite.

The UpdatePanel also includes a PageRequestManager client object that you can manipulate in JavaScript to handle certain events of the UpdatePanel page cycle. For example, you can use the PageRequestManager to notify you when a callback completes or when an error occurs. Using the PageRequestManager gives you more control but requires at least a little bit of JavaScript code in the page.

Microsoft spent a lot of effort on this control ensuring that it works in many different scenarios with no or minimal code changes. Given the variety of scenarios this control needs to address I think they have succeeded in achieving this goal-it works well in most situations.

But there are situations where UpdatePanel will not work correctly-mostly in situations where any controls use client script code that hasn’t been registered through the new ScriptManager control. A ScriptManager is required on any MS AJAX page and it acts as a coordinator that manages script file downloads and a few other page-level operations. The ScriptManager must be used to load script resources and any client-side script code into a page in order for UpdatePanel to recognize the updates to the page (www.west-wind.com/WebLog/posts/9601.aspx). This means that even some Microsoft controls will not work inside of an UpdatePanel-the TreeView and Menu controls, for example. In addition, you can potentially have problems with any third-party or your own custom controls that update client script on postbacks and haven’t been updated specifically to handle MS AJAX.

Developers like to use UpdatePanel because it is mostly server-side technology and they don’t need to deal with JavaScript on the client. But keep in mind that UpdatePanel is also verbose in terms of network traffic and CPU usage on the server as it requires running through a full ASP.NET Page cycle for callbacks.

Client-Side Script Library

Another huge part of the RTM release is the Microsoft AJAX Client Library. This JavaScript library is independent and you can use it in any type of client application including non-Microsoft solutions. It provides core language and type services and introduces many useful constructs like namespaces, interfaces, collections, and delegates that you’re familiar with in .NET. It also extends the existing JavaScript language classes like String, Data and Array, with new functionality and provides many utility functions. In addition, the client script library contains core control classes that wraps the HTML DOM element and base behaviors that extend existing HTML elements on a page.

Most of these controls and behaviors in the client library are pretty bare bones and not meant for application-level use. Rather they offer base functionality that control developers can extend. For example, the ASP.NET AJAX Control Toolkit uses many of these features, as do the more advanced controls in the ASP.NET AJAX Futures library. MS AJAX also includes the core infrastructure for building custom controls and there are specific guidelines both on the client and server side that a control developer has to follow in order to create ASP.NET AJAX controls and behaviors. On the client, control developers must use special constructs like type descriptors and method naming conventions in order for controls to work within the MS AJAX mindset.

The MS AJAX client-side framework provides a ton of useful functionality and much of the code is highly reusable. But it’s not very visible to the average developer-most application-level developers will likely never see the value wrapped up in this client-side library. The library is large and not very discoverable-IntelliSense does not support it to help you along and the documentation is still minimal and only available online. Many of the .NET-like features also vary somewhat from their .NET counterparts, so it’s often frustrating to get functionality to work the way you’d expect it to. The best documentation at this point is the client script source code which Microsoft provided in full with the MS AJAX installation. Using a good JavaScript editor like Aptana (www.aptana.com) goes a long way to let you browse the functionality.

In the final months leading up to release, Microsoft significantly reworked the client-side library and reduced its download footprint. Download sizes can be as low as 24k gzipped with a ScriptManager on the page, but the library footprint will increase as you add functionality and incur additional library downloads. A simple page in release mode with an UpdatePanel on the page loads around 35k of gzipped script resources on the first load. Given the functionality provided by the library this is fairly impressive. Microsoft optimized the resources for caching when running with debug="false" in web.config and in most situations will only load once for a user of the site. It’s a small price to pay for the functionality you gain by utilizing the client JavaScript functionality of MS AJAX.

Network Support

An AJAX framework wouldn’t be very useful without a way to communicate with the server. The MS AJAX client framework includes network support that enables making callbacks to the server. There are both low- and high-level mechanisms available. The low-level WebRequest class provides raw network access with a wrapper around XmlHttpRequest, while Web service and PageMethods callbacks allow a higher level approach that routes client callbacks directly to server code. The latter lets you make RPC-style callbacks to the current page or to Web services. It includes a handler that turns standard ASMX Web services into JavaScript-accessible services using JSON instead of SOAP XML messages. JSON stands for JavaScript Object Notation and is a common serialization format for objects and values that is easy to consume in JavaScript without any parsing code. It’s also more lightweight than XML and has become the preferred data transfer mechanism in AJAX applications. Handling JSON in MS AJAX allows for two-way JSON messaging, which means you can return JSON from the server from a PageMethod or Web service method as well as return a value or object back to the server from client code. The framework handles all the JSON encoding-you’re only dealing with plain values or objects on both ends of the connection. The JSON serializer can deal with most .NET serializable object types, so it’s easy to pass back most custom objects as well as arrays and types of collections (inherited from IDictionary). Unfortunately though, Microsoft moved support for DataTable and DataSet to the Futures release so if you plan on using the 1.0 release only, you have to move any data into objects first or create your own jsonSerialization type converters.

JSON-style callbacks are fairly low level, leaving most of the client-side coding up to you. In my own work I’ve found that I prefer this low-level approach, especially in combination with the MS AJAX client library in updating page content, vastly over using UpdatePanel or other high-level mechanisms because it provides much leaner network traffic and more control when dealing with the result content. This works great for application-level work, but unfortunately you cannot tie these JSON callbacks back to custom server controls directly so it’s not easy for control developers to take advantage of this functionality directly-control developers will have to come up with their own messaging protocols and routing to pass data to their own controls. For those scenarios, the low-level network classes both on the client and the server make it possible to build this on your own, but it’s disappointing that passing data to controls wasn’t a consideration for control developers.

Overall the RTM release is significant in that it provides the core features required to work with AJAX in ASP.NET and it’s an officially supported Microsoft product. Microsoft did a great job getting the base tools fleshed out and solid and has provided a strong base library for component developers to work with.

The key application-level features are the UpdatePanel and Network callback features and the core JavaScript library. This provides for a wide range of usage scenarios, but it isn’t anything that will rock your world. If you’ve done development with other AJAX tools before, you’re likely going to be disappointed by the lack of features and incomplete support for some usage scenarios that Microsoft has pushed off into the ASP.NET 2.0 AJAX Futures library or the ASP.NET AJAX Control Toolkit.

ASP.NET 2.0 AJAX Futures

Much of the functionality that has the potential for making client-side scripting a lot easier and providing some UI glitz that developers associate with AJAX requires using the ASP.NET 2.0 AJAX Futures library and/or the ASP.NET AJAX Control Toolkit, which are not considered officially released products.

Microsoft makes the current Futures releases available as Community Technology Previews (CTP), which means Microsoft typically updates them on a monthly basis. The January 2007 ASP.NET AJAX Futures CTP coincides with the Microsoft ASP.NET AJAX release. Unlike the RTM version, Microsoft has not fixed the Futures feature set so it will likely have major changes over the coming months as Microsoft finalizes the direction of its AJAX tools for the next version of Visual Studio.

The Futures release provides many of the features that Microsoft provided in earlier versions of the ATLAS preview, especially features of the client library. It contains all the client-side glitzy features that provide functionality like opacity, animations, fades, drag and drop, and so on. In addition, the Futures release has more fleshed out control classes, such as label, button, selector (list control), ListView and ItemView that provide better client-side browser-independent scripting support. The Futures release also provides data-binding support for these controls so you can return data from the server and bind it to several of these controls. Over time, functionality has changed drastically in the CTPs and betas, so it’s hard to say how stable these implementations are going to be moving forward.

On the server side there a handful of additional controls, including: the AutoCompleteExtender, which provides Google-like auto suggest functionality; the DragOverlayExtender which makes any control draggable; a ProfileService that provides access to profile functionality on the client; and support for AJAX-enabled Web Parts. The Futures release also provides support for xml-script, which is a declarative XML-based markup language that you can use to attach behaviors and program flow logic. Microsoft originally introduced xml-script in the ATLAS previews and it looked very promising at the time, but due to limited documentation developers found it difficult to use. Using declarative markup to describe how to apply behaviors is sound thinking; it provides an easier way to set properties and bind events than doing the same in code. But without designer and debugging support available, using xml-script has been difficult at best and for the moment at least it has been downplayed by Microsoft. This may change in the future as Microsoft gets into building the designer tools to accompany the AJAX toolset.

The Futures release is not documented in any way that I can find. If you want to work with Futures client code you’ll have to use the JavaScript source as your documentation.

I’m interested to see how Microsoft plans to evolve the Futures release, but I am pretty wary of using it for any production work. Even the ASP.NET AJAX Control Toolkit doesn’t use the Futures release features even for flashy functionality like animation and drag and drop which is provided in the Futures release. Since almost every preview of the ATLAS beta broke previous versions-sometimes drastically-I’m sure that this is likely to continue with these Futures preview releases until closer to the release of the next version of ASP.NET. Until then I’ll continue to treat the Futures release as prototype software from Microsoft.

ASP.NET AJAX Control ToolKit

To make up for the limited control support and as an example of how to build custom controls that extend the functionality of Microsoft’s ASP.NET AJAX library, Microsoft released the ASP.NET AJAX Control Toolkit. It contains 28 easy-to-use controls including the Accordion control (an Outlook-like slider), the ModalPopup control (displays a client control on a shaded background), as well as DropShadow, RoundedCorners, Slider, and an Animation control that lets you easily experiment with a variety of visual display effects. Some controls are super simple like the RoundedCorners and DropDownShadow controls, and some are considerably more complex like the Animation and the ReorderList controls.

The toolkit implements its controls as server controls that you can drop onto a form and configure by setting a few properties. Most controls don’t require any client script although many support optional event hooks that can fire client-side functions.

All the toolkit controls are available with both server and client script source code so you can learn how to build ASP.NET AJAX-enabled controls. The toolkit also comes with a set of helper classes that simplify control development.

The ASP.NET AJAX Control Toolkit is a collaborative effort between Microsoft and the community. A small agile team at Microsoft built the original toolkit then it transitioned over to CodePlex (www.codeplex.com/AtlasControlToolkit/Wiki/View.aspx) where a handful of community developers in addition to the original Microsoft developers contribute new controls as well as fix and update the existing controls.

The controls provided vary somewhat in quality. Some controls are very slick and work perfectly well, others have some quirky behavior or provide visual effects that are not, um, super smooth. Your mileage may vary-make sure you check out the controls thoroughly and make sure they work for your application scenarios. The bottom line is that this is essentially a Microsoft-sponsored community project so don’t expect that these controls have the same quality as controls that make it into a fully-supported Microsoft product or a third-party control library.

Unlike the rest of the AJAX components, the ASP.NET AJAX Control Toolkit has a great sample Web site and a downloadable project that you can easily install and run. You can find documentation as part of the sample Web site and you can easily check the documentation, source, and sample all at the same time.

The ASP.NET AJAX Control Toolkit is a great example of what you can do with the ASP.NET AJAX library and it provides that instant gratification of being able to drop a control on a form and have some useful functionality in minutes that the MS AJAX RTM release on its own lacks.

The Control Toolkit is a separate and optional component that you have to provide with your application and it can be installed in the BIN directory of your Web site or registered in the GAC.

The developers involved in Toolkit maintenance frequently update the ASP.NET AJAX Control Toolkit, although updates to the toolkit controls have been a lot less painful than the main ASP.NET AJAX release. You can expect this toolkit to continue to grow and improve and if you want to build your own control, you can contribute and become a part of the process.

Ready, Set-AJAX

When it comes to using ASP.NET AJAX you have some choices to make. You have to decide which of the components you want to install and run with. To use MS AJAX you have to install the MS AJAX RTM release but you’ll probably want to think hard before using the Futures release as Microsoft will likely continue to change it. The Control Toolkit offers additional components you can install and it’s fairly stable in terms of functionality and backwards compatibility through its versions so it’s probably a safe bet.

The RTM release on its own is pretty light on features so you’ll probably want to at least use the Control Toolkit in combination with it. I’m somewhat disappointed to see that Microsoft did not provide much in the way of client-side controls and any sort of standard data-binding mechanism. After all, much of what developers do is build data-centric applications, yet currently there’s very little provided in this respect.

Third-party companies tend to push the technology envelope. Many major component vendors already have ASP.NET AJAX 1.0-enabled libraries available, so that gives you another option. These vendors provide the data-centric features and client-side library front-ends that make it easy to get data into the client and controls-features that MS AJAX is missing. Check out the controls from these vendors and you might find those slick and highly functional components that provide both client and server APIs. At least explore the options.

Finally, remember that ASP.NET AJAX isn’t your only ASP.NET option. You’ll find many other free and commercial .NET third-party AJAX libraries that provide a similar feature set with a small footprint and might be easier to use. I’ve checked out libraries including Anthem.NET (anthem-dot-net.sourceforge.net), Ajax.NET Pro (www.ajaxpro.info), Lollygag www.lollygagframework.com), and I’ve even built my own light wwHoverPanel (www.west-wind.com/tools/wwHoverPanel). Then there are even more ambitious and innovative efforts like Visual WebGui (www.visualwebgui.com), which allows you to use a Windows Form-like metaphor to build an AJAX application with the framework managing all aspects of rendering very rich user interfaces. On the other end of the spectrum you can also use some of the pure JavaScript libraries including Prototype, Dojo, Yahoo UI library, etc., which provide the client-side functionality and sophisticated control frameworks. In other words, there are a lot of choices out there, and some of them may be a better fit for you than MS AJAX. Take the time to explore your options before following down the Microsoft Yellow Brick Road.

ASP.NET AJAX 1.0 is a solid first release but it’s an interim release on the way to a final destination that’s still a ways off. I hope now that the core engine is complete, Microsoft can focus on creating innovative functionality that is more focused on typical application developer scenarios. In the meantime, Microsoft seems to be very open to community input so get involved and provide as much feedback as you can on the ASP.NET forums for issues, feature requests, and comments, so that the next version provides more functionality that is appropriate for your usage scenarios.