Normally, all the javascript for ASP.NET Ajax is loaded through a custom http handler - namely the ScriptResource.axd handler. However, I host this blog on a subdomain, which seemed to cause some friction with the handler settings in the web.config due to the directory structure my host use for subdomains. I couldn't quite manage to untagle it, so I started looking for other ways to solve this - and that's when I remembered the ScriptPath property that's on the ScriptManager.
Basically, ScriptPath lets you tell ASP.NET Ajax where it should load its javascript files from. If this property is set, it will look for the javascripts in the folder you specify instead of using the ScriptResource.axd handler to load them.
To get this to work, you need to copy all the ASP.NET Ajax javascript source files into some folder on your domain. Now the folder structure here is very important - but luckily it's all lying readily available where ASP.NET Ajax was installed (typically C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025).
Just copy the MicrosoftAjaxLibrary folder onto your site, and you can set the ScriptPath property to ~\MicrosoftAjaxLibrary, and thats it :)
But hang on... what about the Ajax Control Toolkit?
Yup, we need those javascript files aswell to use that. Create the folder AjaxControlToolkit\1.0.10201.0/ within ~\MicrosoftAjaxLibrary, and place all the toolkit client files there - you'll find them in the AjaxControlToolkit\obj\Release folder inside wherever you unzipped the toolkit. Don't forget to use the correct version number for the folder if your toolkit is a newer/older version than in the example above, or you'll be in trouble.
And that's it, ASP.NET Ajax plus the AjaxControlToolkit working like a charm without the ScriptResource.axd. Another great use for this, is if you want to tinker around with the javascript source files.
Basically, ScriptPath lets you tell ASP.NET Ajax where it should load its javascript files from. If this property is set, it will look for the javascripts in the folder you specify instead of using the ScriptResource.axd handler to load them.
To get this to work, you need to copy all the ASP.NET Ajax javascript source files into some folder on your domain. Now the folder structure here is very important - but luckily it's all lying readily available where ASP.NET Ajax was installed (typically C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025).
Just copy the MicrosoftAjaxLibrary folder onto your site, and you can set the ScriptPath property to ~\MicrosoftAjaxLibrary, and thats it :)
But hang on... what about the Ajax Control Toolkit?
Yup, we need those javascript files aswell to use that. Create the folder AjaxControlToolkit\1.0.10201.0/ within ~\MicrosoftAjaxLibrary, and place all the toolkit client files there - you'll find them in the AjaxControlToolkit\obj\Release folder inside wherever you unzipped the toolkit. Don't forget to use the correct version number for the folder if your toolkit is a newer/older version than in the example above, or you'll be in trouble.
And that's it, ASP.NET Ajax plus the AjaxControlToolkit working like a charm without the ScriptResource.axd. Another great use for this, is if you want to tinker around with the javascript source files.
No comments:
Post a Comment