Tip/Trick: Using ScriptManager ScriptPath to load MicrosoftAjax.js from file system
This isn’t particularly tricky but it can be non-obvious.
Create a directory structure under your web application's root directory
You’ll need to create a directory structure that corresponds to the attributes of the assembly that normally contains the script files. In your case you’ll can create a subdirectory structure in your web site like this:
The top directory doesn’t have to be called
Scripts you can call it anything you wish. Since
MicrosoftAjax.js is in the
Microsoft.Web.Extensions assembly, this is why the second directory level is called
Microsoft.Web.Extensions. The final directory is the version number of the DLL. You can see this from your
<compilation debug="false"> <assemblies> <add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, ..."/> </assemblies> </compilation>
C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\ScriptLibrary\Debug
C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\ScriptLibrary\Release
MicrosoftAjax.js from the
Debug directory into your
Scripts\Microsoft.Web.Extensions\1.0.61025.0 directory, and rename it to
Microsoft.Web.Resources.ScriptLibrary.MicrosoftAjax.debug.js. Then do the same for
MicrosoftAjaxWebForms.js following the same pattern of adding “Microsoft.Web.Resources.ScriptLibrary.” to the start of the filename, and then adding “.debug” in front of the “.js”.
Also copy the same files from the
Release directory but this time rename them without adding the “.debug” in front of the “.js”.
Now the source files will be picked up whether or not you are running in debug mode.
Set the ScriptPath on your ScriptManager
Finally, set the
ScriptPath property on ASP.NET ScriptManager to tell it to source the ASP.NET AJAX runtime from your new directory:
<asp:ScriptManager ID="sm1" runat="server" ScriptPath="~/Scripts"> </asp:ScriptManager>