Blog - .NET, ASP.NET, AJAX, Ruby and more
  • Google Banner 2

ASP.NET AJAX ScriptManager JavaScript Files

I have been doing a bit of experimentation with ASP.NET AJAX (in this particular case .NET 3.5) and came across a nice feature of the ScriptManager and what it renders for the Microsoft AJAX JavaScript files. I just thought this sheds a bit more light on the operations of the ScriptManager and ASP.NET AJAX, and since you can never have enough knowledge, here it goes…

As you may or may not know, when you add a ScriptManager to the page, two JavaScript resources are pushed down to browser (via ScriptResource.axd): MicrosoftAjax.js and MicrosoftAjaxWebForms.js. These two files make it possible for you to use the JavaScript Microsoft AJAX Library extensions. Now for the cool part, if you look at MicrosoftAjax.js and MicrosoftAjaxWebForms.js you’ll see it’s very hard to read since there are no line breaks or formatting, and because of this, almost impossible to debug. See Figure 1 below for what MicrosoftAjax.js looks like to the browser.


Figure 1 – MicrosotAjax.js

Now, you may not be seeing this particular view if you fire up Firebug and look for yourself. You may see something more like Figure 2:


Figure 2 – MicrosotAjax.debug.js

That’s MUCH better for debugging, isn’t it? What controls this rendering you ask? Simple, it’s the compilation debug setting your web.config:

<system.web>
  
<compilation debug=true>
      …
   </compilation>
   …
</
system.web>

As I’m sure you aware, compilation debug should be set to false when you deploy your application, but is typically set to true when developing.

While you can see I’m using AJAX in .NET 3.5 in this example, this feature of the ScriptManager holds true for the ASP.NET AJAX Extensions for ASP.NET 2.0.

Hopefully this gives you a little more insight into the operations of the ScriptManager and ASP.NET AJAX. Not sure if you’ve noticed this feature, but it sure is a nice one!

This entry was posted in AJAX, AJAX Control Toolkit, ASP.NET, JavaScript and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.

Damien White is a developer in Connecticut that simply loves coding. Ever since he was young, he has had a driving passion for computers and software development, and a thirst for knowledge that just cannot be quenched. He’s happy to share what he knows in his quest to learn as much as possible.

One Comment

  1. Posted October 10, 2007 at 2:03 pm | Permalink

    Another handy thing to do is download the ASP.NET AJAX source.Then, you’ll have the debug JS files in a folder something like: C:Program FilesMicrosoft ASP.NETASP.NET 2.0 AJAX Extensionsv1.0.61025MicrosoftAjaxLibrarySystem.Web.Extensions1.0.61025.0It’s nice to be able to just open them up on VS and peruse them there.