Using VS 2008 to target ASP.NET AJAX 1.0

Using VS 2008 to target ASP.NET AJAX 1.0

Rate This
  • Comments 60

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.

 

 

Leave a Comment
  • Please add 8 and 7 and type the answer here:
  • Post
  • Ok, I did a couple of things with Visual Studio 2008 today. I rolled back my web config from a web folder

  • I've uninstalled AJAX Extensions 1.0 from my PC and the 3.5 AJAX Extensions in VS2005 disappear, and when I reinstall the 1.0 Extensions the 3.5 Extensions reappear. and this is in VS2005 not VS2008.

  • I have the same problem: AJAX Extensions 1.0 don't appear. I only can view it when select 'Show all', but it appear grayed.

  • Right I fixed VS2005 not showing the correct AJAX Extensions in the toolbox.

    What I did was reinstall the AJAX Extensions 1.0 and then ran the "DisableAjaxPolicy.CMD" command file (as adaministrator on vista). but still the same in VS2008

    Steve :-(

  • I am also experiencing the issue where the AJAX 1.0 controls do not show up in the toolbox after following these steps. I also tried adding the web.config from above to my project, recompiling and then re-adding the AJAX 1.0 controls to the toolbox with no success. The controls are there when I do Show All but I can not access them. Using intellisense I added the ScriptManager and an UpdatePanel to my page and then I get compile errors telling me that the namespace "ScriptManager" and "UpdatePanel" can not be found, even though I have the reference to the AJAX 1.0 assembly in my web.config. This is a new web project in VS 2008, targeted for the 2.0 framework. I am also using WinXP SP2 Tablet PC.

  • The guy who did this post I beleive is looking into this AJAX Extensions and Toolkit not showing in the toolbox he has been able to reproduce the problem on two other PC's.

    So hopefully there will be a workaround or a fix soon.

    Steve

  • Apologies for the delay folks -- My name is Bradley and I am the original author for this post. I have been able to reproduce the toolbox issue and I believe I (finally) understand the cause. I did not see this on the machine I used to write the steps for this blog post due to a subtle difference in machine configuration (I was missing a registry key that your machines will have).

    Here is a proposed workaround (I will edit my post tonight to call this out as well), but it has some side effects too:

    WORKAROUND:

    1. Close VS 2008

    2. Go to \Program Files\Reference Assemblies\Microsoft\Framework\v3.5

    3. Make a backup copy of these two assemblies somewhere on your machine, say under C:\Temp:

    - System.Web.Extensions

    - System.Web.Extensions.Design

    4. Remove these assemblies from  \Program Files\Reference Assemblies\Microsoft\Framework\v3.5.

    Now you should be able to add AJAX 1.0 controls to the Toolbox per the instructions in the post above.  

    Additionally, it appears that this workaround eliminates some of the other "important note" issues mentioned above.  Specifically:

    FIXED - VS will now prompt to upgrade or not upgrade when opening an AJAX 1.0 Website.  You can choose "No" to this prompt to keep the site at 2.0 (without applying the exclude/downgrade/include workaround described above).

    FIXED - Dragging an AJAX 1.0 control from the Toolbox to a page in a 2.0 app no longer warns and adds a 3.5 @Register directive to the page.

    There are some drawbacks to removing System.Web.Extensions 3.5 from the Reference Assemblies folder, however.  Specifically:

    BROKEN - 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).  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.

    BROKEN - 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.

    If you can accept the the two "BROKEN" issues above, then the AJAX 1.0 targeting experience in Beta 2 is much better with this new workaround applied.  Let me know if you try this out and encounter other issues, and I'll investigate further.

    Please also be assured that VS 2008 RTM will *not* require these workarounds.

    Thanks,

    Bradley

  • Thanks Bradley!

    That worked for me, I was able to add the controls to the toolbox and compile. One other thing I did have to do was add the references to the 1.0 System.Web.Extensions and Design DLLs, dragging the controls onto the page did not add them for me.

    Overall I really like this editor though, Visual Studio remains one of the best code editing tools around.

    - Cameron

  • Hey!

    Thanks Bradley, it worked for me too =D

  • Bradley,

    The workaround allowed me to create both Extensions collections (v1.0 & 3.5) and both Toolkit collections, in the toolbox of my Visual Web Developer 2008 B2. Thanks...

    Glenn Michael

  • Thanks Bradley, it's working perfectly now, I'm glad I can use VS2008 for my daily development now.

    Thanks again !

  • There is still something in my environment that prevents showing the both AJAX Extensions and AJAX Control Toolkit in my toolbox. I have followed the instructions by first copying the two dll's to different location, deleting them and then manually creating the new tabs (AJAX Extension, AJAX Toolkit). Then I locate the System.Web.Extensions.dll in \Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025 and click Open but nothing is added to toolbox. Same issue with AJAX Control Toolkit.

  • 这篇文章中,来自微软开发团队的 ScottGu 讲解了 VS2008 和 .Net 3.5 框架的一些新特性,以及下一代 Asp.Net Ajax 的介绍 和 需要注意的问题。

  • Master Pages There is a new default master page. The new default masterpage has content place holders

  • As with Timo, this doesn't work for me, I'm unable to see the assemblies added, even after the delete, it still tries to add v3.5 to my toolbox, not the v1.0.61025

    I had VS2005 installed.  My project is a framework 2.0 project running under VS2008

Page 2 of 4 (60 items) 1234