AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=1397&pId=-1
ASP.NET AJAX in .NET 3.5 and VS 2008
page
by Scott Guthrie
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 33296/ 45

Introduction

Republished with Permission - Original Article

In the past I've blogged about the JavaScript and AJAX improvements with VS 2008 JavaScript Intellisense and VS 2008 JavaScript debugging.  Below are a few notes about some of the ASP.NET AJAX runtime features coming as part of the VS 2008 and .NET 3.5 release, as well as important notes to read if you are opening existing ASP.NET AJAX 1.0 projects in VS 2008.

ASP.NET AJAX included in .NET 3.5

ASP.NET AJAX 1.0 shipped as a separate download that you could install on top of ASP.NET 2.0.  Starting with the .NET Framework 3.5 release, all of these features are built-in with ASP.NET, which means you no longer have to download and install a separate ASP.NET AJAX setup when building or deploying applications.

When you create a new ASP.NET application or web-site in VS 2008 that targets the .NET 3.5 Framework, VS will automatically add the appropriate AJAX registrations in your web.config file and the core ASP.NET AJAX server controls will show up in your toolbox.

Figure 1

The version of ASP.NET AJAX that ships with .NET 3.5 has a number of nice improvements to it - including support for using UpdatePanels with WebParts, support for WCF based JSON end-points, support for using the ASP.NET Profile, Role and Login Application Services using JavaScript, and a number of bug fixes and performance improvements.

Understanding ASP.NET AJAX Versioning

ASP.NET AJAX 1.0 and .NET 3.5 can both be installed side-by-side on the same machine.  ASP.NET AJAX 1.0 is implemented in V1.0 of the System.Web.Extensions.dll assembly.  The implementation of ASP.NET AJAX included with .NET 3.5 lives in V3.5 of the System.Web.Extensions.dll assembly.  The V3.5 of System.Web.Extensions.dll is a fully compatible super-set of the 1.0 implementation (which means you don't need to change any code in order to use it).

Each ASP.NET application on a machine can choose which version of ASP.NET AJAX they want to build and run against.  This is configured via the <system.web.extensions> section in its web.config file, as well as by what System.Web.Extensions.dll assembly it is compiled against (with web-site projects these references are registered in the <assemblies> section of the web.config file, with web application projects they are referenced via the project file). 

You will be able to use VS 2008 to target ASP.NET AJAX 3.5 applications, as well as to use the new VS 2008 multi-targeting support to build ASP.NET 2.0 applications that use ASP.NET AJAX 1.0.  I cover how to-do both in the sections below.

Important Beta 2 Information

A few days before we shipped Beta2 on the web, we discovered a side-by-side issue with ASP.NET AJAX.  If you read my original VS 2008 and .NET 3.5 Beta Released blog post, you'll remember that I called out this post-install patch step to fix this issue:

You should download and run this batch file.  This takes only a few seconds to run, and fixes an issue we found earlier this week with the version policy of System.Web.Extensions.dll - which is the assembly that contains ASP.NET AJAX.  If you don't run this batch file, then existing ASP.NET 2.0 projects built with ASP.NET AJAX 1.0 and VS 2005 will end up automatically picking up the new version of ASP.NET AJAX that ships in .NET 3.5 Beta2.  This will work and run fine - but cause you to inadvertently introduce a .NET 3.5 dependency in the applications you build with VS 2005.  Running the batch file will change the version binding policy of the new System.Web.Extensions.dll assembly and ensure that you only use the new .NET 3.5 ASP.NET AJAX version with projects that you are explicitly building for .NET 3.5.

The good news is that this fixes the side-by-side issue we found, and makes it safe to develop ASP.NET AJAX with both VS 2005 and VS 2008 on the same machine.

The one gotcha is that it causes VS 2008 to incorrectly detect the version of ASP.NET AJAX being used when first opening older ASP.NET 2.0 projects (specifically it can cause VS 2008 to think the project is already using .NET 3.5).  This requires that you to take a few additional steps in Beta2 the first time you open existing ASP.NET AJAX 1.0 web-site projects with VS 2008 to correct this.  You will not need to take these steps with the final VS 2008 release.

Upgrading ASP.NET AJAX 1.0 Applications to use ASP.NET AJAX 3.5

When you use VS 2008 to open an existing ASP.NET 2.0 application that uses ASP.NET AJAX 1.0, you can optionally choose to upgrade the application to use .NET 3.5 (and the version of ASP.NET AJAX included within it).

The VS Web Tools team recently published a Upgrading ASP.NET AJAX 1.0 Websites and Web Applications to .NET Framework 3.5 blog post that describes the step-by-step instructions to accomplish this using VS 2008 Beta2.  The good news is that upgrading an ASP.NET AJAX 1.0 application to .NET 3.5 does not require that you change any of your code, and should take only a few minutes to complete.

As part of upgrading ASP.NET AJAX 1.0 application to .NET 3.5, you'll want to update compiled ASP.NET AJAX control libraries you might be using.  The ASP.NET AJAX Control Toolkit team is now publishing both ASP.NET AJAX 1.0 and .NET 3.5 versions of the AJAX Control Toolkit that you can download here:

Figure 2

The Upgrading ASP.NET AJAX 1.0 Websites and Web Applications to .NET Framework 3.5 blog post covers how to add this ASP.NET AJAX 3.5 version of the AJAX Control Toolkit to the VS 2008 toolbox.

Using VS 2008 to Build ASP.NET AJAX 1.0 Applications (using Multi-Targeting)

When you use VS 2008 to open an existing ASP.NET 2.0 application that uses ASP.NET AJAX 1.0, you can alternatively choose not to upgrade it to .NET 3.5, and instead use the new multi-targeting features of VS 2008 to build it using ASP.NET 2.0 and ASP.NET AJAX 1.0. 

The VS Web Tools team recently published a Using VS 2008 to Target ASP.NET AJAX 1.0 blog post that describes the step-by-step instructions to accomplish this using VS 2008 Beta2. 

Included in the blog post are a number of manual steps you need to take in Beta2 to populate the VS 2008 toolbox with ASP.NET AJAX 1.0 and ASP.NET AJAX Control Toolkit server controls.  For the final release of VS 2008 we'll release a setup package that will automate this for you, as well as add ASP.NET AJAX 1.0 project and item templates to VS 2008 for you to use.

You might be wondering - why is it interesting to target ASP.NET AJAX 1.0 applications using VS 2008 instead of just using VS 2005?  The benefit is that it enables you to build ASP.NET AJAX 1.0 applications that work on your existing servers (no need to upgrade them to .NET 3.5 immediately), while still allowing you to take advantage of some of the new VS 2008 IDE features like JavaScript Intellisense, JavaScript Debugging, better WYSIWYG HTML Designer, CSS management, the improved code editor, unit testing in VS Professional, continuous integration support with TFS, and more. 

Summary

.NET 3.5 now includes built-in support for all ASP.NET AJAX 1.0 features.  I'll be doing more blog posts in the future that also describe how to take advantage of the new features it provides.

You can use VS 2008 to target both existing ASP.NET applications built with ASP.NET AJAX 1.0, as well as target the new version of ASP.NET AJAX built-into .NET 3.5.  The VS Web Tools team blog posts above should help walk you though the step-by-step instructions on how to-do both.

Hope this helps,

Scott

Resources


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-19 1:17:38 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search