Click here to Skip to main content
6,629,885 members and growing! (19,447 online)
Email Password   helpLost your password?
Web Development » Ajax and Atlas » General     Beginner License: The Code Project Open License (CPOL)

Adding ASP.NET AJAX to an Existing ASP.NET Application

By Islam Khalil Saber

How to enable an exisitng ASP.NET application to work as an ASP.NET AJAX application.
XML, HTML, XHTML, Windows, .NET 2.0, ASP.NET, WebForms, Ajax, VS.NET2003, VS2005, Dev
Version:2 (See All)
Posted:20 Nov 2007
Views:24,210
Bookmarked:36 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
8 votes for this article.
Popularity: 3.28 Rating: 3.63 out of 5

1

2
3 votes, 37.5%
3

4
5 votes, 62.5%
5

Introduction

ASP.NET AJAX makes it easy to take advantage of AJAX techniques, and enables you to create ASP.NET pages and take full advantage of the capabilities of the browser to deliver a richer web experience that works on any modern browser.

How to upgrade an existing ASP.NET 2.0 website application by using ASP.NET AJAX?

You add ASP.NET AJAX functionality to an application by adding a reference to the ASP.NET AJAX assembly. You can do this by right clicking on the project folder and then choosing Add Reference, and then from the .NET tab, the assembly System.Web.Extensions; or, you can register it in the web.config file in the Assemblies section as follows:

The Assemblies element:

<system.web>
 <compilation>
   <assemblies>
    <add assembly="System.Web.Extensions, Version=1.0.61025.0, 
                   Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   </assemblies>
 </compilation>
</system.web>

When you add a reference to this assembly, it is added to the Web.config file for your web application. The controls element below registers ASP.NET AJAX namespaces in the System.Web.Extensions assembly and then associates the control in the ASP.NET AJAX assembly with the tag prefix asp. The controls in the ASP.NET AJAX namespaces can be referenced in a web page with syntax such as the following:

<system.web>
 <Pages>
  <Control>
   <add tagPrefix="asp" namespace="System.Web.UI" 
      assembly="System.Web.Extensions, Version=1.0.61025.0, 
                Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <Control>
 <Pages>
<system.web>

Then, we remap the existing ASP.NET validation server controls to the new ASP.NET AJAX validation controls.

You have to define HTTP Handlers and modules that you want ASP.NET AJAX to use. The httpHandlers element adds new handlers for script requests.

<system.web>
 <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"/s> 
   <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>
</system.web>

Here is the HttpModules element:

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

There are also some additional settings that you can add to configure IIS 7 behavior, JSON serialization, ASP.NET authentication, and profile service access. You can do all this by adding another configuration to the web.config file. The Web.config file that is generated contains examples of this additional configuration.

Then, you have to add the script manager control to the website, and when you build your web application, the best place to put the script manager is in the master page to be available to all web pages. Note: you can do this by choking a Web.Config for an existing ASP.NET AJAX web.config file and adding the tag prefix.

I hope you enjoyed the article.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Islam Khalil Saber


Member
Islam Saber is a Software Developer
Occupation: Web Developer
Location: Egypt Egypt

Other popular Ajax and Atlas articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralDeployment Pinmemberjw1232:19 20 Nov '07  
GeneralRe: Deployment PinmemberIslam92:35 20 Nov '07  
GeneralRe: Deployment Pinmemberjw1233:08 20 Nov '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Nov 2007
Editor: Smitha Vijayan
Copyright 2007 by Islam Khalil Saber
Everything else Copyright © CodeProject, 1999-2009
Web22 | Advertise on the Code Project