This becomes much easier with Visual Studio 2008’s built in support for AJAX development and the .NET framework 3.5.
By creating an ASP.NET website or web application Visual Studio 2008 will automatically add the required configuration settings for AJAX in your web config as well as the AJAX controls.
AJAX Project Templates
When you open Visual Studio 2008 to create a new web site/application you will see the following templates
As you can see above those templates include the ASP.NET Web application template which will allow us to setup an AJAX enabled web application project as well as the following two new templates:
- ASP.NET AJAX Server Control
- ASP.NET AJAX Server Control Extender
Project Files for ASP.NET AJAX Server Control & Server Control Extender
The screenshots below show you the project files included for both types of the above projects.
ASP.NET AJAX Server Control
ASP.NET AJAX Server Control Extender
If you closely examine each of the content of the project files below you will notice that they are almost identical despite the name differences. However, they are different. With the AJAX Server Control when the GetScriptDescriptors() method of the behaviour class is called it is passed the client id of the custom control as seen below.
But in the case of the Control Extender we pass the client id of another control
You can find additional information about AJAX Server Controls and Control Extenders in the articles ASP.NET AJAX Controls and Extenders Tutorial and Adding ASP.NET AJAX Client Behaviours to Web Server Controls.
AJAX Extensions Built In Support
As mentioned earlier, when you create a new web application in Visual Studio 2008 it will be AJAX ready by default and there is no need to download the AJAX extensions as was the case in Visual Studio 2005. When you open the tool box in Visual Studio 2008 you will automatically have the AJAX extensions as shown below.
Microsoft AJAX Library
ASP.NET Extensions 3.5 Preview
Another area of new features that you can use with Visual Studio 2008 and ASP.NET AJAX is the ASP.NET 3.5 Extensions which you can download from the AJAX downloads page. When you install the AJAX extensions you’ll see some new project templates such as those for creating ASP.NET MVC applications and Dynamic Data Web applications.
From the list of projects above when you choose the ASP.NET 3.5 Extensions web application template you will see the following extra section of new controls that you can use in you applications including things like SilverLight and the new ListView control.
More information on those controls and how to use them can be found on the ASP.NET 3.5 Extensions Quick Start tutorials page.
One very interesting control in the list of the new controls above is the new ListView control and the reason for that is that it gives you complete control over the generated HTML mark-up. For more information on how you can use the new ListView control along with some other of the extensions preview controls see Scott Guthrie’s post on how to build a product listing page with clean CSS.
Calling Web Services from Client Script in ASP.NET AJAX
Another really great feature with .NET 3.5 and ASP.NET AJAX is easily being able to use client side code to execute server side logic and display results on your ASP.NET page.
This is a great feature that can be very useful when you are not using server controls and what to add some AJAX functionality to your website while being able to use some server side code. This is somewhat similar to what you can do with the AjaxPro library but is baked into the .NET framework. This can be done in three easy steps!
- Create your web service function and declare the web service as a script service
- Configure your application in web config to allow calling a web service from a script
The article Exposing Web Services to Client Script in ASP.NET AJAX explains how you can do this in detail.
Download Visual Studio 2008 90 day trial
For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the Microsoft Visual Studio webpage.
About the Author
Daniel Wissa is a Web Developer working in Christchurch. He has a B.Com. from the University of Canterbury where he studied Information Systems and Computer Science and is also a MCAD in .NET.
He has been involved with Microsoft and Microsoft communities for many years since being a Student Partner at Canterbury University a few years ago to currently leading the Christchurch .NET user group. He also maintains a blog http://www.dan.net.nz where he regularly blogs about Microsoft technologies, local user group events and more.
Other related posts:
The New Zealand ALM Conference 2011 (Application Life Cycle Management)
Writing your own Html Helpers for the ASP.NET MVC Framework
Automating Visual Studio 2008
Comment by Claudio Sanchez, on 10-Apr-2008 07:17
Excellent article to be used as guid and reference for the new VS 2008 templates. Keep up the good work Claudio
Comment by sangam, on 25-Jul-2008 18:14
I liked the post. So many confusions could exist with the new release of visual studio. Posts like this help programmer a lot. Thanks again!
Comment by Gnosis, on 6-Aug-2009 19:16
How to add AjaxExtensions to an existing project ?
Comment by Manoj, on 18-Sep-2009 04:36
Hi , I have installed visual studio 2008 professional edition and when i try to add a new website i dont see any of the Ajax enabled website in the window. I also notice that there is no AJAX Toolkit installed in VS2008 . Do i need to follow any more steps. I have installed visual studio completely . Please Help.....