views:

38

answers:

1

When I use a script manager in Web Forms web applications, where does ASP.Net load the Ajax framework from? (You know the one that provides the $find, $get functions).

I'm looking to replace the built in $find, $get with some extra logic to work around master page name mangling.

Anybody know the best way I can accomplish this?

I'm thinking I can either edit the source file, or inject some script that reassigns the function to my implementation. Just not sure where the best place would be to inject that code.

You can read about my related name mangling master page problem here

Thanks

+2  A: 

The scripts come directly out of the System.Web.Extensions assembly. But you can change where the scripts come from using a script reference, like this:

<asp:ScriptManager runat="server">
    <Scripts>
        <asp:ScriptReference Name="MicrosoftAjax.js" Path="~/scripts/MicrosoftAjax.js" />
    </Scripts>
</asp:ScriptManager>

To get the script, just get the directly out of the rendered page, paste it into the address bar, and download the script.

One thing -- there's actually two versions of MicrosoftAjax.js in the assembly. A release version and a debug version. The debug version has a lot of additional script to do type checking, and is not crunched through a javascript minifier. So you can customize it easily, but the size of the script is going to be pretty big. It wasn't meant to be used in production environments. So I highly recommend you either also customize the release version (which will be very difficult due to having to work with the crunched script) or you reproduce the release version by running your custom script through the Microsoft Ajax Minifier:

http://stephenwalther.com/blog/archive/2009/10/16/using-the-new-microsoft-ajax-minifier.aspx

To get both versions just flip the debug="false" value to "true" and repeat the download step. Name it foo.js and foo.debug.js (foo being whatever you want -- MicrosoftAjax being the obvious choice!)

Also be sure and check out the new ways to change where the scripts come from in ASP.NET 4.0. Just blogged about it here:

http://weblogs.asp.net/infinitiesloop/archive/2009/11/23/asp-net-4-0-scriptmanager-improvements.aspx

InfinitiesLoop