How To: Work with an ASP.NET AJAX 1.0 Web Project in Visual Studio 2008

Multi-targeting support in Visual Studio 2008 lets you work with ASP.NET AJAX 1.0 in new and existing Web sites and Web application projects. You can run existing sites without upgrading them to the newest version of ASP.NET and of the .NET Framework. At the same time, you can develop and maintain an ASP.NET AJAX 1.0 Web site in Visual Studio 2008 and get the benefit of new Visual Studio 2008 features, such as JScript IntelliSense.

Running a Web site by using an earlier version of ASP.NET and of the .NET Framework is useful when it is not practical for you to run the site by using the latest runtime. Examples of when this is useful include the following:

  • The hosting site that hosts your Web site has not upgraded to the most recent version of the runtime.

  • Your Web site has dependencies on controls or components that are not compatible with the current runtime.

Creating a New AJAX 1.0 Web Site in Visual Studio 2008

The following procedures show how to create a new ASP.NET AJAX 1.0 Web site or Web application project by using Visual Studio 2008. The procedure differs slightly between the full version of Visual Studio 2008 and Visual Web Developer Express.

To create a new AJAX 1.0 Web site

  1. Download and install ASP.NET AJAX 1.0. You can download the installation program from the ASP.NET AJAX Web site.

  2. To create a new Web site, do the following:

    1. In the File menu, click New Web Site.

    2. In the New Web Site dialog box, under Visual Studio installed templates, select ASP.NET Web Site.

  3. To create a new Web application project, do the following:

    1. In the File menu, click New Project.

    2. In the New Project dialog box, under Visual Studio installed templates, select ASP.NET Web Application.

  4. If you are using the full version of Visual Studio 2008 (not Visual Web Developer Express) in the target framework list (in the top right corner), select .NET Framework 2.0

  5. Click OK.

    The new Web site or project is created.

  6. If you are using Visual Web Developer Express, change the target framework to 2.0 by doing the following:

    1. In Solution Explorer, right-click the name of the site and then click Property Pages.

    2. In the left list, click Build.

    3. In the Target Framework list, select .NET Framework 2.0.

  7. In the root of the Web site folder, create an ASP.NET AJAX 1.0 Web.config file.

    For a listing of the contents of an ASP.NET AJAX 1.0 Web.config file, see ASP.NET AJAX 1.0 Web.config File Contents later in this topic.

Opening an Existing ASP.NET AJAX 1.0 Web Site in Visual Studio 2008

You can work with an existing Web site or Web application in Visual Studio 2008, without upgrading to the latest version of the runtime.

To open an existing AJAX 1.0 Web site or Web application project

  1. Make a backup copy of the Web site or Web application project.

    If the Web site or project is unintentionally upgraded, the upgrade affects the site's files and cannot be undone.

  2. Open the Web site or Web application project in Visual Studio 2008.

  3. When Visual Studio 2008 prompts you to upgrade the project, click No 

    The project continues to target the .NET Framework 2.0.

Updating the ASP.NET AJAX Control Toolkit Assembly

If your application includes controls or extenders from the ASP.NET AJAX Control Toolkit, you must upgrade to a new version of the Control Toolkit in order to run with Visual Studio 2008. You can download the current version of the ASP.NET AJAX 1.0 Control Toolkit from the Codeplex Web site. Make sure that you get the 1.0 version (the original version) of the library.

Important noteImportant Note:

The Control Toolkit is a community-supported library and is not supported by Microsoft.

After you install the Control Toolkit, you can add the Control Toolkit controls to the Toolbox.

To add the ASP.NET AJAX Control Toolkit controls to the Toolbox

  1. In the ASP.NET AJAX 1.0 Web site or project, open an ASP.NET Web page (Web Form).

  2. Right-click the Toolbox and then click Add Tab.

  3. Give the new tab a name, such as "ASP.NET AJAX Toolkit 1.0".

  4. Right-click the new tab and then click Choose Items….

    Note

    There might be a delay before this dialog box opens for the first time.

  5. In the Choose Toolbox Items dialog box, click Browse… .

  6. Browse to the folder that contains the AJAX Control Toolkit assembly, select AjaxControlToolkit.dll, and then click Open.

    The controls from the Control Toolkit are selected in the Choose Toolbox Items dialog box.

  7. Click OK

    The controls are added to the Toolbox.

You can now work with your AJAX 1.0 Web application in Visual Studio 2008. The application will build and run using the .NET Framework 2.0.

The next time that you open the Web site in Visual Studio, you will not be prompted again to upgrade it. However, you can change the target version of the .NET Framework to .NET Framework version 3.5 at any time. For more information, see How To: Upgrade an ASP.NET AJAX 1.0 Web Project to .NET Framework 3.5.

Using Visual Studio 2008 features in AJAX 1.0 Applications

You can use the new features in Visual Studio 2008 to develop your AJAX 1.0 application, with the following exceptions:

  • The AJAX item templates such as AJAX Web Form and AJAX Master Page are not available in the Add New Item dialog box. To create ASP.NET Web pages or master pages with AJAX support, add an ordinary page to the Web site. Then from the Toolbox, add a ScriptManager control to the page.

  • JScript IntelliSense is not available when you work with the ASP.NET profile service.

  • Extender controls from the AJAX 1.0 Control Toolkit or other ASP.NET AJAX 1.0 third-party control libraries will not support Visual Studio 2008 extender design-time enhancements. For example, they will not support the Choose Extender… smart-tag command in Design view.

ASP.NET AJAX 1.0 Web.config File Contents

To create an ASP.NET AJAX 1.0 configuration file, create a file named Web.config and then paste the following XML into it:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <system.web>
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </controls>
    </pages>
    <compilation debug="true">
      <assemblies>
        <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>
    <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>
  </system.web>
  <system.web.extensions>
    <scripting>
      <webServices>
        <!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
        <!--
          <jsonSerialization maxJsonLength="500">
            <converters>
              <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
            </converters>
          </jsonSerialization>
        -->
        <!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
        <!--
          <authenticationService enabled="true" requireSSL = "true|false"/>
        -->
        <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
             and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
             writeAccessProperties attributes. -->
        <!--
          <profileService enabled="true"
            readAccessProperties="propertyname1,propertyname2"
            writeAccessProperties="propertyname1,propertyname2" />
        -->
      </webServices>
      <!--
        <scriptResourceHandler enableCompression="true" enableCaching="true" />
      -->
    </scripting>
  </system.web.extensions>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated"/>
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </handlers>
  </system.webServer>
</configuration>

See Also

Concepts

.NET Framework Targeting for Web Sites

Migrating and Converting ASP.NET Web Sites

Overview: Converting Visual Studio Web Sites and Projects to Visual Studio 2008