Skip navigation

The ASP.NET Ajax Library Takes Shape

Features that make the ASP.NET Ajax Library interesting for web developers

It's been no secret that Microsoft has long had big plans for AJAX 4.0, the version that will ship with Visual Studio 2010 and ASP.NET 4.0 in March 2010. Until recently, the preview releases were just a few JavaScript files that dramatically improved AJAX on the client, giving it much richer interface and data-binding features than versions released to date. Cool stuff, but pretty not exactly a full product.

Now that Microsoft has released the official beta, there are plenty of tools and goodies for creating rich interactive web pages, as well as some great tools to help with development. Collectively, the tools are the ASP.NET Ajax Library. That's the official name, even though you may occasionally see it as the Microsoft Ajax Library. So much for easily Googling (Binging?) information about the library.

You can get all the details about the library at the references I've included at the end of this article. Microsoft is cranking out blog posts and marketing materials that get into the nitty gritty of the library, and I won't regurgitate that here. Instead I want to talk about a few features that really make the Ajax Library interesting for web developers generally, whether you develop with ASP.NET or not.

Microsoft Embraces Open Source
Microsoft recently set up the CodePlex Foundation to "enable the exchange of code and understanding among software companies and open source communities." It provides a way for Microsoft to embrace open source software, allowing community participation—real participation—and a way to release intellectual property with an open source license. Even as I write these words I feel a bit odd, using them in the same paragraph as "Microsoft." But it seems to be a genuine initiative by the company to provide a fertile environment for collaborative development and making the results widely available.

Time will tell how successful the foundation will be, but the first project gallery is the ASP.NET Open Source Gallery, and the first project in that gallery is the ASP.NET Ajax Library project. The foundation plans to release the library with full source code under a BSD open source license. This is a simple license that allows redistribution and use of code in both source and binary forms, as long as you include the appropriate copyright notice and a limited liability disclaimer. In other words, you can do pretty much whatever you want with the library, including extending it as you see fit. And you can even contribute enhancements to it.

Calling it the CodePlex Foundation is a bit unfortunate, however. The foundation has nothing to do with Microsoft's CodePlex site, and Codeplex.com will remain a site that hosts open source, collaborative projects.

New Client-Side Ajax Control Toolkit
The Ajax Control Toolkit has long been available as a relatively easy way to add AJAX features to ASP.NET web pages. It has included both server-side controls and extenders, letting you add features like watermarks, masked edits, auto-complete controls, and many others, providing all the client-side JavaScript to make the magic happen.

The beta of the Ajax Library now includes a client-side version of most of the controls, completely implemented in JavaScript. Here's an example of using the Watermark control:

<script type="text/javascript">
    Sys.require(Sys.components.watermark, function () \\{
        Sys.create.watermark("#firstName", "Enter First Name Here");
    \\});
</script>

With that code, everything necessary to turn the element with ID firstName into a watermark is done on the client side.

All the old server-side controls and extenders will still be available, with lots of enhancements. Best of all, Microsoft will now support the toolkit, both client and server versions, as part of its support for the Ajax Library.

SSL Support in the Content Delivery Network
In September 2009, Microsoft announced the AJAX Content Delivery Network (CDN), in which it would host the JavaScript files that comprise the Ajax Library, as well as the main jQuery library. (See my article "Microsoft's AJAX Content Delivery Network" for more information.) This means that you don't have to host those files on your own web server. Instead, you can set the src attribute to point to Microsoft's servers and suck up their bandwidth instead of your own, for both commercial and non-commercial use.

A great benefit of this is that a browser can cache the files across multiple websites, so it doesn't need to download the exact same file over and over from different servers.

To use the CDN, simply set up your script tag like this:

<script src="http://ajax.microsoft.com/ajax/beta/0911/MicrosoftAjax.js" type="text/javascript"></script>
<script src="http://ajax.microsoft.com/ajax/beta/0911/MicrosoftAjaxTemplates.js" type="text/javascript"></script>

 

<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

You can also use the CDN from the ASP.NET 4.0 ScriptManager server control by setting the EnableCdn attribute to true. The CDN includes both production and debug versions of the script files.

When the CDN was first announced, there was no support for SSL. This means that your users would get the dreaded message that the page includes both secure and insecure data if you used the CDN in a page that uses SSL. Microsoft has fixed that shortcoming, and now you can use the HTTPS protocol to grab the script files.

There is a lot to learn and love in the beta of the ASP.NET Ajax Library. Be sure to check out client-side templates and data binding, the Ajax Minifier to compress your JavaScript files, and integration with jQuery.

References
Information and download for the ASP.NET Ajax Library
http://www.asp.net/ajaxlibrary/

Good overview of the first beta of the ASP.NET Ajax Library with lots of links
http://www.jamessenior.com/post/News-on-the-ASPNET-Ajax-Library.aspx

PDC 2009 video with James Senior and Stephen Walther, discussing the library beta (note that you can either stream the video or download it in various formats for offline viewing)
http://channel9.msdn.com/posts/jsenior/Introducing-the-ASPNET-Ajax-Library-Beta/

Scott Guthrie's original blog post about the Microsoft Ajax CDN
http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx

Documentation on the CDN
http://www.asp.net/ajaxLibrary/cdn.ashx

BSD license information from the Open Source Initiative
http://www.opensource.org/licenses/bsd-license.php


Don Kiely ([email protected]), MVP, MCSD, is a senior technology consultant, building custom applications and providing business and technology consulting services. His development work involves tools such as SQL Server, Visual Basic, C#, ASP.NET, and Microsoft Office.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish