Jess Chadwick

Your Friendly Neighborhood Webinary
Using the ASP.NET AJAX Client Library without a ScriptManager

In the post just before this one, I talk a little bit about using the ASP.NET AJAX client library to help ease the pain of client-side development, but I don't actually mention or give any server-side examples or code snippets. Well, there's a good reason for that:  the ASP.NET AJAX client-side library does not require the ScriptManager or any other server controls! 

Actually, let me say it a bit differently:  when you add a ScriptManager control to your page, it "enables" or makes ASP.NET AJAX available for use on that page, which effectively means that the client-side library is added as a script reference in the markup and is therefor subsequently downloaded and available for use on the client.  However - since all it is is a JavaScript file - if you feel the need to use the ASP.NET AJAX Client Library on your page without adding a ScriptManager on the server side (like, oh, in an ASP.NET MVC view when you can't add a ScriptManager?), you can still feel free to add a reference to it yourself!  Actually, it's pretty easy...

Finding it is the hard part.

Where is MicrosoftAjax.js?

I quite honestly don't know the best answer to this question, but here are two places to look:

  • ASP.NET 2.0 (Futures):  If you've ever installed one of the older versions of the ASP.NET AJAX framework (via one of the Futures bundles) and used the default install directory, you should be able to get the raw file for the ASP.NET 2.0 version here:
    • C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\MicrosoftAjaxLibrary\System.Web.Extensions\1.0.61025.0\MicrosoftAjax.js
  • ASP.NET 3.5:  With the release of Visual Studio 2008 came .NET 3.5, in which the ASP.NET AJAX libraries were included.  AFAIK, the client-side framework is no longer stored as raw files, but now served up as a Web/ScriptResource.  If that really is the case, I think the best way is to create a throw-away WebForm, add the ScriptManager to it, use something like FireBug or Fiddler to determine the URL, and save a local copy. (Important: save the local copy!  If you decide to instead use an existing production site with a ScriptManager on it, I don't think you can count on the URL to the ScriptResource remaining the same... at least I wouldn't!)

After using one of these methods to get the library, I generally save a local copy of it in my project (alongside the rest of my scripts) and add a reference to it just as you would any other external JavaScript file.

Now all that's left is to enjoy the ASP.NET AJAX client-side love!

Posted: 11 Jul 2008, 15:48
Filed under:
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS