Adding ASP.NET AJAX to Existing Websites

September 22, 2007 – 8:27 am

If you want to add Microsoft ASP.NET 2.0 AJAX Extensions 1.0 to an existing website…

Click here for the video! 

First, install the ASP.NET AJAX 1.0 Extensions: ASP.NET 2.0 AJAX Extensions 1.0

Next, add some stuff to the web.config file:

In the system.web section add the following line:

    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </controls>
    </pages>

This will save you having to have the following directive at the top of each page:

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

If you find you are getting the nasty "'Sys' is undefined error on your pages, putting the following into the System.Web section will fix this:

    <httpHandlers>
      <remove verb="*" path="*.asmx"/>
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>

    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpModules>

Thats it!  All you should need to do now is just drop a script manager and update panel on the page and throw the controls you want to AJAX-enable in them and you are locked and loaded.

Thanks to Darryl Burling for the tip!

You must be logged in to post a comment.