Telerik blogs

UPDATE: Visual Studio 2010 does not have the Ajax-Enabled Web Site template as well. It always creates an ajax enabled web sites/applications, so what you need to do is just check if the ScriptManager is on your page.

If you use RadControls for ASP.NET Ajax with Visual Studio 2005 you should be familiar with the Add New > ASP.NET Ajax-Enabled Web Site template. This is the option that you often choose in the add New Web Site dialog:

New Ajax Enabled Web Site template

Selecting this template gives you two benefits:

1. Your web.config file is automatically configured to use ASP.NET Ajax so you do not have to do anything manually.

2. The default page comes with the ScriptManager control on it so you do not have to add it manually.

Unfortunately, this template is no longer available in Visual Studio 2008:

New Web Site - Visual Studio 2008

The reason is that Visual Studio 2008 by default creates a .NET 3.5 application. Since ASP.NET Ajax is included in the framework – this template is missing. So, when you create a new ASP.NET Web Site with Visual Studio 2008 all you get is a pre-configured web.config file. The default page is lacking the ScriptManager so you have to add it manually.

Fortunately, you can add a new Ajax Web Form as shown below:

New Ajax Web Form Visual Studio 2008

Now your page will have the ScriptManager automatically added on it. Furthermore, it will contain the pageLoad() method declaration in the <head> tag. Note that if you are going to use code blocks (i.e. <% ... %>) in the pageLoad() method you need to move it out of the <head> tag to prevent the exception:

Error message “The Controls collection cannot be modified because the control contains code blocks"

 

Fortunately, you can download the Microsoft ASP.NET 2.0 AJAX Templates for Visual Studio 2008 from here. After installing them you will be able to choose again your favorite option in Visual Studio 2008 – Ajax 1.0-Enabled ASP.NET 2.0 Web Site:

Ajax Enabled Web Site VS2008

Note that selecting this option will create a .NET 2.0 web site using the Ajax Extensions 1.0 (despite the .NET version in the dropdown is 3.5).

 

I hope you will find this information useful.


About the Author

Iana Tsolova

is Product Manager at Telerik’s DevTools division. She joined the company back in the beginning of 2008 as a Support Officer and has since occupied various positions at Telerik, including Senior Support Officer, Team Lead at one of the ASP.NET AJAX teams and Technical Support Director. Iana’s main interests are web development, reading articles related to geography, wild nature and latest renewable energy technologies.

Comments

Comments are disabled in preview mode.