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 4 and 6 and type the answer here:
  • Post
  • I followed your instructions but still have problems getting web application to compile and run.  I am creating a new web application project under VS2008 B2.  After doing that, I copy in the Ajax 1.0 web.config.  At this point, I get an error: ~\Default.aspx: ASP.NET runtime error: Failed to start monitoring changes to '~\WebApplication1\WebApplication1\Default.aspx'

    No matter what else I do, I still get this error.

    This is installed in a VM using Vista Business (x86) wth Office 2007 Professional installed in the VM.

  • Fixed that error. It was a security error connecting to the physical harddrive on the host computer.

  • Wow, that's a lot of important notes ;-)

    I think I'll just use VS 2008 for new (test) projects and won't be upgrading current projects, there's no 3.5 hosting so why take the risk?

  • Vs2008 B2 keeps telling me that there are no usable controls in this group.. (for a asp.net 2.0 project)

    And no matter what I do..( have run the policy script several times now) hitting F5 always pops up with the message 'The Framework required by assembly 'AjaxcontrolToolkit.dll' or one of it's dependencies is higher then the project target framework. Would you like ro add this reference to your project anyway?

    I cannot figure out how to get the toolkit show up in the toolbox also..

    Any advise? I have been changing 2.0 -> 3.5 -> 2.0 now. but cannot figure out what I am doing wrong.

    By adding

    <assemblies>

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

                   <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

                   <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

                   <add assembly="System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

               </assemblies>

    to the webconfig I can run the project.. but it requires that I do the ajax compnentplacement by hand.

    So any advice is welcome here!

  • Hi,

    I have a similar problem as Michael Hensen.

    I've opened a VS2005 solution with an asp.net 2.0 web application project in VS2008 Beta2 after I ran the DisableAjaxPolicy script and the /resetsettings switch for VS 2008.

    The conversion of the project files completed with no errors.

    But no items are showing in the toolbox when I add components from the System.Web.Extensions.dll.

    I've tried the same thing with AJAX Control Toolkit but still no items get added to the Toolbox.

    When I run the web application I get the parser error: "Could not load file or assembly 'System.Web.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.".

    If I change the "Version" to "1.0.61025.0" in the Register Assembly directive on the web forms, the site runs fine.

    P.S. I'm running on Vista and also have VS2005 installed. The Beta1 of VS2008 has been uninstalled.

    Thanks.

  • Same here, I can't add the items in the toolbox. Though there's no error after adding the System.Web.Extensions.dll (but still no items in the toolbox shows up)

  • Two good posts by the Web Development Tools team that you should read if you are already working on AJAX

  • It seems that the items actually are added to the toolbox but not available in the context.

    If you right-click on the toolbox and select "Show All" the AJAX 1.0 components are visible but not useable.

    So maybe its just a matter of configuration of the current web application to get access to the added AJAX 1.0 components.

    Any help on this is much appreciated!

    Thanks.

  • I've just done a fresh install of Windows Vista Ultimate 32bit installed VS2008 Beta2 as per ScottGu's blog instructions and then installed VS2005.

    I am following the above instructions "Step Two:  Install ASP.NET AJAX 1.0 Controls to the VS 2008 Toolbox" but after browsing to the "System.Web.Extensions.dll" the copenents do not appear in the list and no Icons appaer in the toolbox.

    The same as the guys above :-(

    Steve

  • PS I've just checked oput what Mads said "If you right-click on the toolbox and select "Show All" the AJAX 1.0 components are visible but not useable" and mine are not there only an empty tab the 3.5 AJAX extensions are there when you show all.

    Steve

  • Re AJAX Extensions and Toolkit not appearing.

    If I add my own custome controls they appear :-/

    Still puzzled

  • Experimenting further if I try and add the AJAX Toolkit for .Net 3.5 it does'nt appear in the toolbox either.

    Steve

    :-/

  • The plot thickens In VS2005 I now have AJAX Extensions 3.5 showing and cannot add toolkit or extensions for ASP.Net 2.0

    Steve

  • Does the Ajax ASP.Net team even monitors this post? Can't seem to hear anything. A confirmation of the bug would be very helpful....

  • I'm experiencing the same symptoms as Mads.

    The items only show up when you do 'show all' and the are grey-ed out for usage on a website project that targets the 2.0 framework.

Page 1 of 4 (60 items) 1234