Saturday, January 9, 2010

Configuring ASP.NET AJAX

Configuring ASP.NET AJAX
Introduction

This topic describes the elements in the Web.config file that support Microsoft ASP.NET AJAX. It also describes how to incorporate those elements into the Web.config file for an existing ASP.NET application.
Using the ASP.NET AJAX Web Configuration File in a New Web Site

When you create a new AJAX-enabled Web site, you can use the Web.config file provided in the installation package to add the required configuration settings. In Visual Studio, the Web.config file for Microsoft ASP.NET AJAX is included in your project when you create a new ASP.NET AJAX-enabled Web Site.

If you have to manually add the Web.config file to a new Web site, you can get a copy of it from the installation path. By default, the file is in the following location:

drive:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.nnnn

Adding ASP.NET AJAX Configuration Elements to an Existing Web Site

In an existing Web site, you typically have values in the Web.config file that you want to retain. In that case, you can add the new ASP.NET AJAX elements into the existing Web.config file.

The new elements are part of the following configuration sections:

*

The element
*

The element
*

The element
*

The element
*

The element
*

The element
*

The element

The Element

The element creates a configuration section and subsections for the SystemWebExtensionsSectionGroup class. You set the properties for these sections in the element.

The following example shows the element for ASP.NET AJAX. Add this section to the existing Web.config file as a child of the element.



type="System.Web.Configuration.SystemWebExtensionsSectionGroup,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35">
type="System.Web.Configuration.ScriptingSectionGroup,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35">
type="System.Web.Configuration.ScriptingScriptResourceHandlerSection,
System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
requirePermission="false"
allowDefinition="MachineToApplication"/>
type="System.Web.Configuration.ScriptingWebServicesSectionGroup,
System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35">
type="System.Web.Configuration.ScriptingJsonSerializationSection,
System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
requirePermission="false" allowDefinition="Everywhere" />
type="System.Web.Configuration.ScriptingProfileServiceSection,
System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
requirePermission="false"
allowDefinition="MachineToApplication" />
type="System.Web.Configuration.ScriptingAuthenticationServiceSection,
System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
requirePermission="false"
allowDefinition="MachineToApplication" />






The Element

The element registers ASP.NET AJAX namespaces in the System.Web.Extensions assembly and maps the asp tag prefix as an alias for these namespaces. The controls in the ASP.NET AJAX namespaces can be referenced in a Web page with syntax such as the following:



The following example shows the element for ASP.NET AJAX. Add this section to the existing Web.config file as a child of the element.









The Element

The element registers the System.Web.Extensions assembly.

The following example shows the element for ASP.NET AJAX. Add this section to the existing Web.config file as a child of the element.









The Element

The element adds new handlers for script requests.

The following example shows the element for ASP.NET AJAX. Add this section to the existing Web.config file as a child of the element.










The Element

The element defines HTTP modules used in ASP.NET AJAX.

The following example shows the element for ASP.NET AJAX. Add this section to the existing Web.config file as a child of the element.







The Element

The element provides elements that can be uncommented to configure how Web services are called from Microsoft ASP.NET AJAX applications. The element is used to specify custom type converters and to override default settings for JSON serialization. The element specifies custom type converters. The element is used to enable or disable the authentication service. The element is used to enable or disable the profile service and to specify which properties are exposed by the service. The element is used to enable or disable caching and compression of resources used with scripts.

The element, element, and element can be defined only in the Machine.config file or in the Web.config file in the application root directory. The element can be defined in the Machine.config file, in the Web.config file in the application root directory, or in a Web.config file in a subfolder of the Web site.

The following example shows the element for ASP.NET AJAX. Add this section and its subsections to the existing Web.config file as a child of the element.
















The Element

The element contains configuration settings used by Microsoft Internet Information Server (IIS) 7.0.

The following example shows the element for ASP.NET AJAX. Add this section to the existing Web.config file as a child of the element.




preCondition="integratedMode"
type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>



preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"/>
verb="GET,HEAD" path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />



See Also
reference By:
http://www.asp.net/ajax/documentation/live/ConfiguringASPNETAJAX.aspx

Installing ASP.NET AJAX

Installing ASP.NET AJAX
Introduction

This topic describes how to install Microsoft ASP.NET AJAX. It also describes how to install the optional ASP.NET 2.0 AJAX Futures CTP and optional ASP.NET AJAX Control Toolkit.
ASP.NET AJAX

ASP.NET AJAX enables you to create dynamic Web pages that support partial-page updates. It includes Microsoft ASP.NET 2.0 AJAX Extensions, which is a server framework, and the Microsoft AJAX Library, which consists of client script that runs on the browser.
note

The installation process installs the ASP.NET AJAX assembly (System.Web.Extensions.dll) in the global assembly cache (GAC). Do not include the assembly in the Bin folder of your AJAX-enabled Web site.

You can install and use ASP.NET AJAX with Microsoft Visual Studio 2005 or Microsoft Visual Web Developer Express Edition. However, you do not require Visual Studio 2005 to use ASP.NET AJAX to create ASP.NET Web applications.

You can install and use the Microsoft AJAX Library without the .NET Framework. You can also install it on non-Windows environments to create client-based Web applications for any browser that supports ECMAScript (JavaScript).
ASP.NET 2.0 AJAX Futures CTP

The CTP release is community supported. The features in the CTP release might be added to the supported features in future versions of ASP.NET AJAX. The CTP release is compatible with ASP.NET AJAX.
ASP.NET AJAX Control Toolkit

The ASP.NET Control Toolkit provides features that extend functionality of ASP.NET AJAX version 1.0. These features enhance the depth and breadth of the platform and include new ideas and concepts. The ASP.NET Control Toolkit is community supported and community driven.
System Requirements for Installation

Microsoft ASP.NET AJAX requires the following software.
Supported Operating Systems

*

Windows Server 2003
*

Windows XP Home Edition
*

Windows XP Professional
*

Windows Vista
*

Any Windows operating system version (including Windows 2000) that supports the Microsoft .NET Framework version 2.0. Note that support will be limited to the terms of support for that platform.

Required Software

*

The .NET Framework 2.0 or version 3.0.
*

Internet Explorer 5.01 or later.

Optional Software

*

Microsoft Visual Studio 2005 or Visual Web Developer Express Edition

Installing Microsoft ASP.NET AJAX

Follow these steps to install ASP.NET AJAX.
To install Microsoft ASP.NET AJAX

1.

Make sure that you are logged in with an account that has Administrator rights.

If your account does not have Administrator rights, the installation process displays the error "The system administrator has set policies to prevent this installation."
2.

Uninstall any earlier versions of ASP.NET AJAX. If the installation process finds an earlier version on your computer, it will stop.

You can remove earlier versions with the Add or Remove Programs application in Control Panel.
3.

Download the ASPAJAXExtSetup.msi installation package from the ASP.NET AJAX Downloads Web site.
4.

To install ASP.NET AJAX from the Windows interface, double-click ASPAJAXExtSetup.msi in Windows Explorer.

By default, the .msi file is installed in the following location:

drive:\..\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.nnnn.

5.

To install ASP.NET AJAX from the command line, execute the following command at a command prompt:

msiexec /i ASPAJAXExtSetup.msi [/q] [/log ] [INSTALLDIR=]

Specify the /q option to perform the installation without user prompts. You can optionally provide an installation path and a file name for logging. If you do not provide an installation path, the default installation path is used.
6.

If you want to add the ASP.NET 2.0 AJAX Futures CTP, download and install it from the ASP.NET AJAX Downloads Web site.
7.

If you want to add the ASP.NET AJAX Control Toolkit, download and install it from ASP.NET AJAX Control Toolkit Web site.

Using ASP.NET AJAX with Visual Studio

If you have Microsoft Visual Studio 2005 installed on your computer, the installation process installs templates for AJAX-enabled Web site projects. It also installs an assembly (AJAXExtensionToolbox.dll) that extends the Visual Studio toolbox. When you create a new AJAX-enabled Web site by using Microsoft Visual Studio 2005, the template automatically includes the Web.config file that includes the elements required for ASP.NET AJAX components.

To add ASP.NET AJAX components to an existing site, modify the Web.config file in the Web application by using the configuration values from the sample Web.config file in the installation path. For more information about ASP.NET AJAX configuration values, see Configuring ASP.NET AJAX.
Using ASP.NET AJAX Without Visual Studio

If Microsoft .NET Framework version 2.0 is installed on a computer without Microsoft Visual Studio 2005 or Visual Web Developer Express Edition, the ASP.NET AJAX installation process adds the System.Web.Extensions.dll assembly that contains server components to the global assembly cache. It also copies a sample Web.config file to the installation path. It does not install templates for AJAX-enabled Web site projects or install the assembly for extending the Visual Studio toolbox.

You can use ASP.NET AJAX in a Web application by adding the sample Web.config file from the installation folder to the Web site directory. You can also modify the Web.config file in an existing Web application by using the configuration values from the sample Web.config file. For more information about the ASP.NET AJAX configuration values, see Configuring ASP.NET AJAX.
Installing the Microsoft AJAX Library on Non-Windows Environments

You do not have to build a Web site on a Windows-based environment to use the client framework provided by the Microsoft AJAX Library. The Microsoft AJAX Library consists of JavaScript files and will work with any browsers that can run JavaScript code.
note

The Microsoft AJAX Library is installed with the full installation. You do not have to install the Microsoft AJAX Library separately if you have completed the full installation.
To install Microsoft AJAX Library

1.

Download the MicrosoftAJAXLibrary.zip package from the ASP.NET AJAX Downloads Web site.
2.

Unzip the MicrosoftAJAXLibrary.zip package.
3.

Copy the JavaScript files to the Web site.

See Also
reference By:
http://www.asp.net/ajax/documentation/live/InstallingASPNETAJAX.aspx

Using VS 2008 to target ASP.NET AJAX 1.0

Using VS 2008 to target ASP.NET AJAX 1.0

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 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 in your page:







Path="~/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js" />







· 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.

reference By:
http://blogs.msdn.com/webdevtools/archive/2007/07/30/using-vs-2008-to-target-asp-net-ajax-1-0.aspx

Upgrading ASP.NET AJAX 1.0 Websites and Web Applications to .NET Framework 3.5

Upgrading ASP.NET AJAX 1.0 Websites and Web Applications to .NET Framework 3.5

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.



Microsoft Visual Studio 2008 Beta 2 is finally released, and with it comes a bunch of great new features for writing and maintaining ASP.NET AJAX applications. Additionally, a new version of ASP.NET AJAX is included in the .NET Framework 3.5, which includes improvements over the current ASP.NET AJAX 1.0 release. This article walks you through the steps you’ll need to follow to upgrade your existing ASP.NET AJAX 1.0 Websites and Web Application Projects to use the AJAX support in .NET Framework 3.5 and Visual Studio 2008 Beta 2.



Note: With the new Multitargeting support in Microsoft Visual Studio 2008, It is also possible to continue maintaining ASP.NET AJAX 1.0-based Websites and Web Application Projects in VS 2008 without upgrading them. Click here to learn the steps you can take to maintain and/or create new ASP.NET AJAX 1.0 applications using Microsoft Visual Studio 2008 Beta 2.



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. 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. This issue and workaround is described in more detail below.



Step One: Upgrade Your ASP.NET AJAX Website



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 migrate the project.

3. When Visual Studio 2008 prompts to upgrade the Website or Web Application, select “Yes”



Framework Version Prompt



Important Note: 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, following these steps:



1. Right-click the project node in Solution Explorer, and choose “Properties”

2. Click the “References” tab

3. Click the reference to “System.Web.Extensions” version 1.0.6 and click the “Remove” button

4. Click the “Add Reference” button

5. Switch to the “Browse” tab

6. Browse to the backup location for the 3.5 version of System.Web.Extensions.dll under \Program Files\Reference Assemblies\Microsoft\Framework\v3.5\Backup and click “OK” to add this reference.


Step Two: Update the ASP.NET AJAX Control Toolkit assembly


If your application uses the ASP.NET AJAX Control Toolkit, you will need to follow these additional instructions to update the toolkit assembly in your application to a new release that works with .NET Framework 3.5:



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 3.5 (choose one):

a. AjaxControlToolkit-Framework3.5-NoSource.zip

b. AjaxControlToolkit-Framework3.5.zip (includes source code)

3. In Windows Explorer, right-click the zip file and choose “Extract All…” to extract the contents to an “AjaxControlToolkit-Framework3.5” folder in the same directory

4. Copy the AjaxControlToolkit.dll assembly from AjaxControlToolkit-Framework3.5\SampleWebSite\Bin to your application’s Bin directory, replacing the previous version of the toolkit assembly



(Optional): Install the ASP.NET AJAX Toolkit controls to the VS 2008 toolbox

You can also populate the toolbox in VS 2008 with the ASP.NET AJAX Toolkit controls by following these instructions:



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 “ASP.NET AJAX Toolkit 3.5”

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



5. In the Choose Toolbox Items dialog, click the Browse… button

6. Browse to \AjaxControlToolkit-Framework3.5\SampleWebSite\Bin, select AjaxControlToolkit.dll, and click the “Open” button.



Toolbox Choose Items Dialog Browse



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



Step Three: Update Web.config to allow 3rd-party AJAX 1.0 components to use .NET Framework 3.5



As described above in Step Two, a new version of the Microsoft ASP.NET AJAX Control Toolkit is available that is compiled against the ASP.NET AJAX (System.Web.Extensions) assembly in .NET Framework 3.5. However, your application may also be using 3rd-party components/assemblies that were compiled against ASP.NET AJAX 1.0. In order for these components to continue working under the .NET Framework 3.5, you must add the following bindingRedirect section to the Web.config file of your ASP.NET AJAX 3.5 application. This causes the 3rd-party component to bind to the 3.5 version of System.Web.Extensions instead of the 1.0 version.





















Important: For this configuration to work, ASP.NET AJAX 1.0 must also be installed to the machine.



The bindingRedirect only applies at runtime, so at design-time the third-party component will still be referencing System.Web.Extensions 1.0. As a result, you may encounter the following issues:



· If the third-party component is an ExtenderControl, it will not get the VS 2008 ExtenderControl designer enhancements.

· You will not get intellisense for references to scripts inside the third-party assembly.

· You may get this warning when building your site: “Assuming assembly reference 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' matches 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35', you may need to supply runtime policy.”

reference By:
http://blogs.msdn.com/webdevtools/archive/2007/07/28/upgrading-asp-net-ajax-1-0-websites-and-web-applications-to-net-framework-3-5.aspx

VS 2008 JavaScript Debugging

VS 2008 JavaScript Debugging

A few weeks ago I blogged about the new JavaScript Intellisense support in VS 2008.

One of the other JavaScript features that I'm sure will be popular in VS 2008 is the much-improved support for JavaScript debugging. This is enabled in both the free Visual Web Developer 2008 Express edition as well as in Visual Studio, and makes using JavaScript and building AJAX applications significantly easier.
Setting JavaScript breakpoints in ASP.NET pages

One of the annoying things with VS 2005 is that you have to first run your ASP.NET pages before you can set JavaScript breakpoints in them in the debugger.

VS 2008 makes this much better by adding new support that allows you to set client-side JavaScript breakpoints directly within your server-side .aspx and .master source files:

When you set a breakpoint in your .aspx page like above, VS 2008 will automatically map the breakpoint location to the dynamically generated client HTML that runs in the browser when the page is later executed:

If you add/remove/update the breakpoint locations in the running HTML document, VS 2008 is also now smart enough to perform the reverse mapping and update the breakpoint in the original .aspx or .master source file on the server. This makes it much easier to get into a nice edit/debug/edit/debug flow as you are iterating on your applications.

Best of all, you can now set both client-side JavaScript breakpoints and VB/C# server-side breakpoints at the same time (even in the same page) and use a single debugger to step through both the server-side and client-side code in a single debug session (which is extremely useful for any AJAX heavy application).

Any JavaScript breakpoints you set will also now by default be saved by VS 2008 when you close the project/solution. When you open up the project again, the previous locations you set the breakpoints on will still have them enabled.
Script Document Navigation within the Solution Explorer

Often the JavaScript that is sent down to a browser client is dynamically generated on the server (for example: with scripts that are stored as resources within compiled server controls - like ASP.NET AJAX UpdatePanels and control extenders). In scenarios such as these, you want to be able to easily see all JavaScript URLs being loaded from a page, as well as step into the within the debugger.

VS 2008 makes it much easier to-do this by integrating the running Script Document feature (that in VS 2005 was a separate tool-pane window) into the VS 2008 solution explorer view when you are debugging a web application.

Specifically, when you are using VS to run and debug a page, VS 2008 will now list all of the script URLs that the page you are debugging has loaded in the browser at the top of your VS solution explorer pane:

You can then double click on any of the URLs under the "Script Documents" node at the top to see the JavaScript file that was loaded in the page:

You can obviously then set breakpoints in the loaded JavaScript and debug everything.
Much Richer Debug Watch/Locals and Visualizer Support

Easily opening and navigating JavaScript files in the debugger is nice - but the real meat of the improvements made with VS 2008 JavaScript debugging is in the much improved object execution and inspection support. When you inspect a variable within the debugger using VS 2008, you'll find much more detailed object information is now available:

You can now browse runtime object methods:

You can now browse runtime object events:

And you now get much, much more detailed property and property type information of running objects. Note below how I am traversing the div element's "parentElement" property to dynamically look up details about the element's parent HTML element and overall position within the HTML DOM:

You can obviously use the debugger property grid above to both lookup as well as set values. You can also run code in the immediate window to retrieve and change JavaScript at runtime:

VS 2008 also provides support for pluggable debug visualizers that you can use with JavaScript debugging. This enables developers to add extensions to the debugger that can work against running objects and provide richer visualization views of them. For example, we could use the built-in "Text", "XML", or "HTML" visualizer to load a dialog to better inspect a value:

I suspect we might see a cool CodePlex project providing nice JSON and REST JavaScript visualizers soon.

Reference By:
http://weblogs.asp.net/scottgu/archive/2007/07/19/vs-2008-javascript-debugging.aspx

ASP.NET AJAX in .NET 3.5 and VS 2008

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 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 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,

Reference By :
http://weblogs.asp.net/scottgu/archive/2007/07/30/asp-net-ajax-in-net-3-5-and-vs-2008.aspx

Tuesday, May 5, 2009

Aspx Session use in Java Script

function OpenWind()
{
<% if( HttpContext.Current.Session["Id"]==null) { %>
alert('Session Expired! Redirecting to login page!');
location.href= 'logout.aspx';
<% } %>
var SessionId = <%= HttpContext.Current.Session["Id"].ToString() %>;
window.open('adduser.aspx?Mode=E&&Id='+SessionId+'','AddUser',"resizable,scrollbars,menubar,location,status,toolbar,titlebar,scrollbar");
}

and the calling mark up is this



But this fails gives me object reference not set to an instance error when HttpContext.Current.Session["Id"] is null.

.........................................

from where you are assigning HttpContext.Current.Session["Id"].ToString() the value ?


get the values if not null

<% if( HttpContext.Current.Session["Id"] !=null) { %>
var SessionId = <%= HttpContext.Current.Session["Id"].ToString() %>;

<% } %>


..................................

Hello

Assign Session variable like this

Session["Id"] = Context.Session.LCID;

then check as ur condition

<% if( HttpContext.Current.Session["Id"]==null) { %>
alert('Session Expired! Redirecting to login page!');
location.href= 'logout.aspx';
<% } %>
var SessionId = <%= HttpContext.Current.Session["Id"].ToString() %>;
.........