Using VS 2008 to target ASP.NET AJAX 1.0

Web Development Tools Microsoft

8/10/2007 UPDATE:  This blog post was edited to include simplified instructions to work around a known issue w/ Multitargeting support in VS 2008 Beta 2.  See “Machine Prerequisites” below.

 

In a previous post, I described the steps you can take to upgrade your existing ASP.NET AJAX 1.0-based Web sites to use the new AJAX functionality in .NET Framework 3.5.  However, you may also need to maintain existing AJAX 1.0-based sites without upgrading them, or even continue creating new AJAX 1.0-based sites.  Fortunately, the Multitargeting support in Visual Studio 2008 allows you do just that.  Using Visual Studio 2008, you can still write and maintain applications using .NET Framework 2.0 (and AJAX 1.0), while also reaping the benefits of all the new features in VS 2008 such as the new WYSIWYG design surface, CSS management features, Jscript Intellisense, and Jscript debugging.  In this post, we’ll look at the steps you can follow to either maintain an existing ASP.NET AJAX 1.0 application in VS 2008, or create a new ASP.NET AJAX 1.0-based application in VS 2008.  If  you decide to move forward to the AJAX functionality in .NET Framework 3.5 at a later time, you can simply follow these steps to upgrade.

 

Machine Prerequisites:

 

1.       Download and install Microsoft Visual Studio 2008 Beta 2

2.       After the Beta 2 installation has finished, you should run this script to ensure that the installation of .NET Framework 3.5 Beta 2 will not affect the development of ASP.NET AJAX 1.0 applications.  You should do this immediately after installing VS Beta 2.

3.       Download and install ASP.NET AJAX 1.0.

4.       Apply the following workaround to fix a known issue with Visual Studio’s Multitargeting support for AJAX 1.0.  Note that this workaround will *not* be required for the VS 2008 RTM release:

 

Workaround to Fix VS 2008 Beta 2 Multitargeting Support for AJAX 1.0

 

    1.  In Window’s Explorer, go to this folder:
         \Program Files\Reference Assemblies\Microsoft\Framework\v3.5

    2.  Create a folder entitled “Backup” at this location

    3.  Make a back-up copy of these two assemblies in the new “Backup” folder, and
         then delete them from \Program Files\Reference Assemblies\Microsoft\Framework\v3.5:

 

               System.Web.Extensions.dll

               System.Web.Extensions.Design.dll

  

Note:  This workaround causes two known side effects to Web Application Projects in VS 2008:
 

Creating a new 3.5 Web Application Project has a “broken” reference to System.Web.Extensions 0.0.0.0 in the client references list (Project Properties > References).  If you build the project, you will encounter this error:  The referenced assembly “D:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.dll” was not found. If this assembly is produced by another one of your projects, please make sure to build that project before building this one. In order to correct this, you need to manually remove this reference, then Browse… to the location of the System.Web.Extensions 3.5 backup you made in step 3 above to add the reference back to the project.

 

When upgrading a Web Application Project that uses AJAX 1.0 to .NET Framework 3.5, VS doesn’t remove the reference to System.Web.Extensions 1.0.6 in the client references list (Project Properties > References).  You need to manually remove this reference and then Browse… to the location of the System.Web.Extensions 3.5 backup you made in step 3 above to add the reference back to the project. 

 

Step One:  Create or Open Your AJAX 1.0 Website or Web Application in VS 2008

 

To Create a New AJAX 1.0 Website or Web Application:

 

If you want to create a new AJAX 1.0 Website or Web Application in VS 2008, follow these steps:

 

1.       In the File menu, choose New Website… and select “ASP.NET Website”

a.       To create a Web Application Project instead, choose “New Project…” and select “ASP.NET Web Application” in the language of your choice

2.       In this dialog’s top-right corner, change the Target Framework version dropdown to 2.0.

 

 New Website Dialog 2.0

 

a.       Note that in Visual Web Developer Express, there is no Target Framework dropdown in the New Website dialog.  Instead you must create the project first and then downgrade the Target Framework to 2.o in the Website Property Pages dialog (under the Build tab).

 

2.       Copy the  ASP.NET AJAX 1.0 Web.config file to your project root folder

3.       Follow the instructions in Steps Two and Three below to populate the Toolbox with AJAX 1.0 controls

 

To Open an Existing AJAX 1.0 Website or Web Application:

 

If you have an existing ASP.NET AJAX 1.0 Website or Web Application Project (i.e. built using VS 2005) that you want to continue maintaining in Visual Studio 2008, follow these steps:

 

1.       First, make a backup of your project, then launch Microsoft Visual Studio 2008 Beta 2.

2.       In the File menu, choose Open Website… to open your Website’s folder or IIS virtual directory

a.       If you are opening a Web Application project instead, choose “Open Project…”, and navigate to the project file to open it.  Follow the steps of the Visual Studio Conversion wizard to convert the project file to the VS 2008 format.

3.       When Visual Studio 2008 prompts to upgrade the Website or Web Application, select “No” to keep the Target Framework as version 2.0.

 

Framework Version Prompt (No) 

 

 Step Two:  Install ASP.NET AJAX 1.0 Controls to the VS 2008 Toolbox

 

By default, Visual Studio 2008 does not display ASP.NET AJAX 1.0 controls in the toolbox when you are targeting .NET Framework 2.0 (this is because AJAX 1.0 is a separate download from VS 2008, and the AJAX 1.0 installer only adds templates/controls to VS 2005).  In order to make the AJAX 1.0 controls available in VS 2008, you need to populate the toolbox manually using these steps:

 

1.       Open a Web Form (.aspx page) in your project

2.       Right-click the Toolbox and choose “Add Tab”

3.       Give the new tab a name, such as “AJAX Extensions 1.0”

4.       Right click underneath the new tab and select “Choose Items…” (note that it can take awhile to bring up the this dialog for the first time)

 

Toolbox Choose Items AJAX 1.0 

 

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

6.       Browse to \Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025, select System.Web.Extensions.dll, and click the “Open” button.

 

Toolbox Choose Items Dialog Browse AJAX 1.0 

 

7.       You should see the toolkit controls selected in the Choose Toolbox Items dialog.  Click OK to add these controls to the toolbox.

 

Toolbox Choose Items Dialog AJAX 1.0

 

After confirming this dialog, the ASP.NET AJAX 1.0 controls will appear in your toolbox.  You can verify that these are the 1.0 controls by hovering over a control in the Toolbox and looking for the tooltip containing version number 1.0.61025.0.

 

 

Important Note:  These controls will continue to be displayed in applications that target .NET Framework 3.5, so be careful not to accidently add them to pages in those applications (you should use the AJAX Extensions controls included in .NET Framework 3.5 instead).

 

Toolbox AJAX 1.0 Tooltip 


Step Three (Optional): Download and Install the ASP.NET AJAX Toolkit Controls to the VS 2008 Toolbox

 

If your application uses the ASP.NET AJAX Control Toolkit, you will need to follow these similar instructions to populate the toolbox in VS 2008 with the ASP.NET AJAX Toolkit controls.  If you already have downloaded the Toolkit to your machine, you may skip steps 1-3.

 

1.       Click here to go to the ASP.NET AJAX Toolkit Release page

2.       Download the latest version of the toolkit for .NET Framework version 2.0 (choose one):

a.       AjaxControlToolkit-NoSource.zip

b.      AjaxControlToolkit.zip (includes source code)

3.       In Windows Explorer, right-click the zip file and choose “Extract All…” to extract the contents to an “AjaxControlToolkit” folder in the same directory

4.       In Visual Studio 2008, Open a Web Form (.aspx page) in your project

5.       Right-click the Toolbox and choose “Add Tab”

6.       Give the new tab a name, such as “AJAX Toolkit 1.0”

7.       Right click underneath the new tab and select “Choose Items…” (note that it can take awhile to bring up the this dialog for the first time)

8.       In the Choose Toolbox Items dialog, click the Browse… button

9.       Browse to \AjaxControlToolkit\SampleWebSite\Bin, select AjaxControlToolkit.dll, and click the “Open” button.

10.   You should see the toolkit controls selected in the Choose Toolbox Items dialog.  Click OK to add these controls to the toolbox.

 

Important Note:  These controls will continue to be displayed in applications that target .NET Framework 3.5, so be careful not to accidently add them to pages in those applications (you should use the AJAX Control Toolkit released for .NET Framework 3.5 instead).

 

Conclusion

You can now continue building and maintaining your .NET Framework 2.0 + AJAX 1.0 Web application in Visual Studio 2008.  When you close and re-open your project in Visual Studio, you will not be prompted to upgrade it again, although you can upgrade to .NET Framework 3.5 at any time by following these steps.  Additionally, there are many great new features of Visual Studio 2008 Beta 2 that you can use to develop your AJAX 1.0 application (see the links at the top of this post), although there are few caveats about developing AJAX 1.0 applications in Visual Studio 2008 that are worth calling out:

 

·         The AJAX item templates such as “AJAX Web Form” and “AJAX Master Page” not available in the Add New Item dialog of a .NET Framework 2.0 application.  You can instead add a regular Web Form or Master Page template, and add the <asp:ScriptManager> control from the toolbox.

·         JScript Intellisense always displays members from the AJAX 3.5 scripts.  Although these scripts are backward-compatible with AJAX 1.0, Jscript Intellisense may display members that are unavailable in AJAX 1.0.  To get AJAX 1.0-based Intellisense, you can copy the entire System.Web.Extensions folder from the AJAX 1.0 installation directory (typically under \Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\MicrosoftAjaxLibrary) and then add an explicit script reference to the 1.0 MicrosoftAjax.js script on the <asp:ScriptManager/> in your page:

 

    <asp:ScriptManager ID=”ScriptManager1″ runat=”server”>

      <Scripts>

        <asp:ScriptReference Name=”MicrosoftAjax.js”
         Path=”~/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js” />

      </Scripts>

    </asp:ScriptManager>

 

·         Jscript Intellisense against Web Services (registered in ScriptManager) or the ProfileService (enabled in Web.config) is unavailable in an AJAX 1.0 application.

·         Extender controls from the AJAX 1.0 Control Toolkit or other AJAX 1.0-based 3rd-party control libraries will not get the VS 2008 Extender design-time enhancements (i.e. the “Choose Extender…” smart task in Design View).

·         You will not get intellisense for references to scripts inside third-party assemblies.

 

 

0 comments

Discussion is closed.

Feedback usabilla icon