ASP.NET AJAX in .NET 3.5 and VS 2008

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.

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:

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

40 Comments

  • Hi Scott,
    When will you blog about ListView control (with DataPager control)? :)

  • i don't know understand real purpose of ajax based master page and would u pls tell us how can we do page level navigation thru asp.net ajax, means i don't want when i redirect to other page of my site - post back happen.

  • Hi Scott! What about the problem with compatibility between ASP.NET 2.0 and the ASP.NET 2.0 SP1 code that gets generated when using multi-targeting in VS2008? 2.0 sites built on a dev machine with VS2008 doesn't run on servers with only ASP.NET 2.0 because of some incompatibilities introduced in ASP.NET 2.0 SP1.

    We get these "Could not load type 'System.Web.UI.HtmlControls.HtmlTableBodySection' from assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'." errors when trying to run applications that are built and deployed without distributing the source code to the production server. This happens when the server doesn't have ASP.NET 2.0 SP1 that obviously is installed with the 3.5 framework.

    /Per

  • Hi Scott,
    So we can use the 3.5 ajax bits now for live sites? Also, if i install the beta 2 VS 2008, will it be hard to uninstall it when the rtm comes out? Just dont want to break any existing 2.0 stuff.

  • Do you know any hoster which is providing .Net 3.5 hosting. I want to try the stuff in real world and see how it performs.

    One more question Do you have any link to download aproject based on LINQ which uses linq to sql in the DAL.

  • Once I opened a 2005 project in 08 (I created an 08 solution and added existing projects) i can no longer open my pages because of the following error.

    System.Web.HttpParseException: Could not load file or assembly 'System.Web.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) --->

    This is a ASP.NET 2.0 App made up mostly of user controls. In my web.config i am still referencing 1.0.6 of system.web.extension. So i opened it in VS 05 and i am getting the same error. I tried removing and re-adding the reference to system.web.extensions so that it points to 1.0.6 and i'm still getting this error. Any ideas on how to get my reference back would be greatly appreciated.

  • I actually found the problem on my previously posted question - you have to remove and re-add the reference to the AjaxControlToolkit as well as the system.web.extensions. Thanks for the new toys!

    Ryan

  • In your Channel 9 screencast you mentioned that you can now use "web parts" with update panels (when asked about differences between Beta 1 and Beta 2). We could do that before by putting the update panel inside the web part. Does this mean in Beta 2 you can now "wrap" web parts with an update panel (like you could in the beta of AJAX over a year ago)?

  • Scott,

    Are the changes to ASP.NET 2.0 that supported a richer CSS/DIV implementation (CSS Control Adapter Toolkit) now built into the new version, or is that something that remains external to the default rendering? If not, are there plans to incorporate it?

    I tried looking through some of your earlier posts for word on this, but only found that the Toolkit was released as beta.

    Cheers,

    James

  • Great post Scott...

    Can you post the links to send in feedback about VS 2008, AJAX and Javascript Intellisense? I tried out a few things over the weekend and noticed some features that are not working as they should. I am hoping they can be fixed for the final.

  • This will be great to produce websites like VoyageMap.com that use AJAX heavily but had to be built using separate download for AJAX 2.0

  • Hi Per,

    >>>>>>> Hi Scott! What about the problem with compatibility between ASP.NET 2.0 and the ASP.NET 2.0 SP1 code that gets generated when using multi-targeting in VS2008? 2.0 sites built on a dev machine with VS2008 doesn't run on servers with only ASP.NET 2.0 because of some incompatibilities introduced in ASP.NET 2.0 SP1.

    >>>>>>> We get these "Could not load type 'System.Web.UI.HtmlControls.HtmlTableBodySection' from assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'." errors when trying to run applications that are built and deployed without distributing the source code to the production server. This happens when the server doesn't have ASP.NET 2.0 SP1 that obviously is installed with the 3.5 framework.

    This was unfortunately a breaking change that made its way into .NET SP1 Beta (which .NET 3.5 Beta2 installs). We are following up now, though, to try and get this fixed for the final release.

    Hope this helps,

    Scott

  • Hi Scott;
    Question about WPF:
    I notice when I drop a control on the form, there are no events to wire up code. You had mentioned that as of beta 2, the feature list is locked. Does this mean that with production version, we still don't get "Events" in designer?

    Secondly, in WPF there is a button between code and design that you can shift your code to top or bottom, but in ASP editor, the code always goes to the top. Is there a way we can have the design to go to top in ASP?

  • Hi James,

    >>>>>>> Are the changes to ASP.NET 2.0 that supported a richer CSS/DIV implementation (CSS Control Adapter Toolkit) now built into the new version, or is that something that remains external to the default rendering? If not, are there plans to incorporate it? I tried looking through some of your earlier posts for word on this, but only found that the Toolkit was released as beta.

    We are planning on improving the output and styling of existing controls in the future. For .NET 3.5 one of the big controls we are shipping is the ListView (which I'll blog about shortly) - it has full markup and CSS customization support and I think you'll find it extremely handy.

    BTW - the 1.0 release of the CSS Control Toolkit shipped last year: http://weblogs.asp.net/scottgu/archive/2006/11/29/tip-trick-use-the-asp-net-2-0-css-control-adapters-for-css-friendly-html-output.aspx It provides a solution today for existing controls to use.

    Hope this helps,

    Scott

  • Hi Brennan,

    >>>>>> Can you post the links to send in feedback about VS 2008, AJAX and Javascript Intellisense? I tried out a few things over the weekend and noticed some features that are not working as they should. I am hoping they can be fixed for the final.

    If you want to send me email (scottgu@microsoft.com) with any issues you find, I can then loop in the right folks on my team.

    Thanks,

    Scott

  • Hi Bart,

    >>>>>> In your Channel 9 screencast you mentioned that you can now use "web parts" with update panels (when asked about differences between Beta 1 and Beta 2). We could do that before by putting the update panel inside the web part. Does this mean in Beta 2 you can now "wrap" web parts with an update panel (like you could in the beta of AJAX over a year ago)?

    Yes - you can now wrap controls like WebPartZonss and CatalogueManagers with UpdatePanels, and then also optionally have UpdatePanels within individual webparts for more localized AJAX handling.

    Thanks,

    Scott

  • Scott,

    I have a question about LINQ. I know that it isn't related to this posting so feel free to delete it, but I figured that you would be checking on here and not wanting to wade back through much older posts (or are you automatically notified of a comment?) In any case, here goes:

    I want to pass a System.Data.Linq.Table to a function, but the function doesn't know which table type it is being passed. I want to be able to pass the table to be queried and a bunch of pairs of "columns/vals" that restrict the query by using where statements.


    public void MyFunction (System.Data.Linq.Table, SOME PARAMETERS)

    How can I achieve this sort of generic querying in a function? I tried accepting an IQueryable but the compiler couldn't find the 'Select' statement to query with...do I need to use extensive reflection? It almost seems like in this case building out a standard ADO.NET call might be easier, but I doubt it given the power I have seen so far with LINQ. Let me know what the right approach is.

    Thanks,

    Bill Konrad

  • Scott,
    I have a project that was originally built with beta 1 that I am back porting to the 2.0 framework for a release that targets both versions properly. However, after installing beta2, followed by AJAX 1.0 Extensions and applying the patch (reboot), my project is still not able to reference the proper version of the assembly. The 1.0.61025 references are grayed out. I will continue to try to find a solution but hope that you can provide me with one sooner than I can find one :)

    Thanks,
    -Jim

  • Hi Jim,

    >>>>>>> I have a project that was originally built with beta 1 that I am back porting to the 2.0 framework for a release that targets both versions properly. However, after installing beta2, followed by AJAX 1.0 Extensions and applying the patch (reboot), my project is still not able to reference the proper version of the assembly. The 1.0.61025 references are grayed out. I will continue to try to find a solution but hope that you can provide me with one sooner than I can find one :)

    Two things to do:

    1) Make sure in the project properties window that your multi-targeting support is set to .NET 2.0.

    2) Rather than use the assembly library list to select the System.Web.Extensions.dll assembly, you should use the "browse" functionality to select it off the disk. This blog post: http://blogs.msdn.com/webdevtools/archive/2007/07/30/using-vs-2008-to-target-asp-net-ajax-1-0.aspx covers how to select this.

    If you still have problems send me email (scottgu@microsoft.com) and we can help.

    Thanks,

    Scott

  • Hi Denny,

    >>>>>>> I'm having an issue getting the JavaScript intellisense to pick up the JS hints (as described here: weblogs.asp.net/.../vs-2008-javascript-intellisense.aspx).
    I created a new project and created some JavaScript files. I added the hints to the JS but am not getting the correct types. It seems to default to an object type unless I explicitly set the variable.
    Were the JavaScript hints implemented in beta 2?

    Can you send me an email (scottgu@microsoft.com) that repros this issue? You should be seeing the JavaScript intellisense hints working - so it would be good to understand what is going wrong.

    Thanks,

    Scott

  • Hi Ben,

    >>>>>>>> Question about WPF: I notice when I drop a control on the form, there are no events to wire up code. You had mentioned that as of beta 2, the feature list is locked. Does this mean that with production version, we still don't get "Events" in designer?

    In design-mode the WPF designer currently only supports double-clicking to add the "default" event on a control. The roadmap plan is to enable wiring up all events via the property grid as well (like you can with Windows Forms and ASP.NET). We are still working to figure out whether this will be done in the final VS 2008 release or in SP1.

    What you can do today, though, is wire-up events in the XAML source-view. If you type the event name on the element it gives you the ability to automatically create the event handler in your code-behind. This works in Beta2 today.

    >>>>>> Secondly, in WPF there is a button between code and design that you can shift your code to top or bottom, but in ASP editor, the code always goes to the top. Is there a way we can have the design to go to top in ASP?

    That is a good question that I'm not 100% sure of. I agree this would be cool to configure - I'll need to follow up to see if this is possible.

    Thanks,

    Scott

  • I got AJAX 1.0 working, however, there are many problems with VS2008 using the AJAX 1.0 Extensions. Of course the documented warning about adding a reference to the extensions.dll pops up everytime you add an AJAX control, but further, any control you drop into a ajax control gets you the warning, and most of the time will not sync into the ajax control if you drop it into the designer. This bug alone makes it virtually impossible to develop like that.

    Where do I report bugs in VS2008 so you can get this nuked?

    Thanx.

  • Hi Scott, yet another fantastic article! This might not be the best place for this, but I was wondering if I could request an article on WPF/XAML. Specifically, using stuff like TreeViews and Toolbars seems to be way different. Are these controls complete? I think I need to get a XAML book or something. I can't figure out how to add nodes to the treeview, or buttons to the toolbars (through the designer).

    Thanks :)

  • One thing I just want to know How Can I install Ado.net entity on VS 2008?

  • Hi Scott,

    Does beta2 support javascript intellisense in web application project model? I have tested it with no luck. However, it works fine in web site model.

    What I have done..
    1. create a new web application project.
    2. drag script manager to a page.
    3. create javascript block and try to find out $get...

  • When I cut and paste the pasted text remains highlighted. Is there an option to turn this off? I thought is was where you could uncheck the option to have an ID automatically generated but I can't find it. Thanks!

  • Scratch that. It was the Format HTML On Paste option that was causing that.

    --- Ken

  • I have some problems adding the old AJAX controls to the toolbox. When I "choose items" and browse for the System.Web.Extensions.dll in my ASP.NET v1.0.61025 folder, I get the new AJAX controls (3.5) added to (and selected in) the list of .Net Framework Components - just like I had chosen the new dll.

    When I try the same with the AJAX Control Toolkit, I've got an error telling me that the "request or permission failed".

    I reset the VS, run the batch (your previous post) and made sure the multi targeting is set to 2.0

  • Why are the AJAX configurations still in the web.config instead of moved to the machine.config? Some (most) settings (and the configsections) can be moved to machine.config right? Is that in the planning or is there a good reason to keep the web.config 'cluttered'?

    Thanks!

  • Hi Flo,

    >>>>>> I have some problems adding the old AJAX controls to the toolbox. When I "choose items" and browse for the System.Web.Extensions.dll in my ASP.NET v1.0.61025 folder, I get the new AJAX controls (3.5) added to (and selected in) the list of .Net Framework Components - just like I had chosen the new dll.

    Can you send me an email (scottgu@microsoft.com) with details of this problem? I can then get someone to help you.

    Thanks,

    Scott

  • Hi Adam,

    >>>>>> Hi Scott, yet another fantastic article! This might not be the best place for this, but I was wondering if I could request an article on WPF/XAML. Specifically, using stuff like TreeViews and Toolbars seems to be way different. Are these controls complete? I think I need to get a XAML book or something. I can't figure out how to add nodes to the treeview, or buttons to the toolbars (through the designer).

    I'll be covering WPF and XAML more in blog posts in the future. One book I highly recommend checking out to really learn WPF is Adam Nathan's WPF Unleashed book here: http://www.amazon.com/gp/product/0672328917/104-9219624-7383145?ie=UTF8&tag=scoblo04-20&linkCode=xm2&camp=1789&creativeASIN=0672328917 If you look at the review ratings on Amazon you'll see that it has received really stellar ratings.

    Hope this helps,

    Scott

  • Hi Mike,

    >>>>>>> Why are the AJAX configurations still in the web.config instead of moved to the machine.config? Some (most) settings (and the configsections) can be moved to machine.config right? Is that in the planning or is there a good reason to keep the web.config 'cluttered'?

    Unfortunately we couldn't add the AJAX references to the global web.config file without causing side-by-side compatibility problems with existing ASP.NET AJAX 1.0 applications. We could have renamed the settings to avoid the conflict - but then people with ASP.NET AJAX 1.0 applications would have had to update their code.

    We are, though, for RTM going to make a pass through the web.config file for the RTM release and clean up the default template in VS. It is too cluttered right now and can be a lot cleaner/smaller.

    Hope this helps,

    Scott

  • Thanks for your reply Scott. I actually have that book and I agree, it is a great book. I'm actually more curious about using the Designer. I guess my question should have been: is the designer feature-complete (not is the "control" complete)? I'm very impressed how far it's gone since Beta 1, but it seems like it's missing some things like the events list and I'm having trouble adding buttons to toolbars and stuff through the designer. Doing it through XAML is cake, it's definitely way easier than changing .designer.cs code :). I look forward to your blog post(s) about WPF/XAML :).

    Thanks!

  • >>>>>> Unfortunately we couldn't add the AJAX references to the global web.config file without causing side-by-side compatibility problems with existing ASP.NET AJAX 1.0 applications.

    I don't get it, the settings would be in the global configuration for .NET 3.5. How is that a problem for AJAX 1.0 applications, they are running on .NET 2.0 or 3.0 right? So then they wouldn't see the new configuration...

  • Hi Mike,

    >>>>>> I don't get it, the settings would be in the global configuration for .NET 3.5. How is that a problem for AJAX 1.0 applications, they are running on .NET 2.0 or 3.0 right? So then they wouldn't see the new configuration...

    The configuration files for applications are versioned using the CLR version, and not the framework library versions. .NET 3.5 uses the same CLR version as .NET 2.0 - and so share the same root web.config file. That is why putting the configuration settings there would cause conflicts.

    Hope this helps,

    Scott

  • Hi Scott,

    I was expecting to find some aspects of the ASP.NET Futures release in Ajax 3.5, particularly support for xml-script and client controls. No such luck.

    Could you please let us know if XML-Script is dead? I've been using it for a few months and am very pleased with our overall performance gains compared to the UpdatePanel mode. The slowness of IE's DOM maniuplations makes the listview almost useless, but other than that it's really great. XML property binding and the "glitz" package make for really nice AJAX UIs. XML-Script seemed to be to AJAX what XAML is to SilverLight, I'd be disappointed to see it go down the drain.

    Thanks a bunch.

  • Hi Amanda,

    Sorry you are running into issues! Are you still having problems? If so, can you send me email (scottgu@microsoft.com) and I'll have someone help you.

    Thanks,

    Scott

  • Hi Stephane,

    >>>>> I was expecting to find some aspects of the ASP.NET Futures release in Ajax 3.5, particularly support for xml-script and client controls. No such luck.

    We have a new ASP.NET AJAX Futures release that works with AJAX 3.5 (and it contains the XML-Script support). Unfortunately because of the schedule we weren't able to get more new features into AJAX 3.5 - but we are planning another AJAX release next year that will add more.

    Hope this helps,

    Scott

  • I am having problems with an AJAX site when deployed to the server (partial page rendering is working fine locally).

    There are no compilation/assembly binding errors and the web.config file is consistant locally and on the server.

    The server is Win2k sp'd up with the 3.5 runtime installed.
    Locally I'm on Vista with VS 2008 running just happily.

    I've reduced a page to a simple test of a button & label in an updatepanel. Again, locally, clicking the button updates the label without a refresh, but on the server the whole page gets the postback.

    I guess what I'm wondering is if there's a checklist or troubleshooting guide to verify an install or otherwise figure out what's breaking where.

    Cheers,
    James

  • Hi James,

    >>>>>> I am having problems with an AJAX site when deployed to the server (partial page rendering is working fine locally).

    If you want to send me email (scottgu@microsoft.com) with more details about the issue I can have someone try and help.

    Thanks,

    Scott

Comments have been disabled for this content.