Friday, March 13, 2009

Quick Way to integrate AJAX with MOSS 2007

If you are developing custom web pages in MOSS 2007, and wanna use AJAX cool features in your pages, then you have to make few changes in you web.config file.

Here i will explain you some easy steps what you have to do to get AJAX 1.o work with your MOSS 2007 application.

First of all Install AJAX extension v 1.0, can be downloaded from http://www.asp.net/ajax/

If you are using VS 2008, .Net 3.5, don't worry just follow below steps. In your case just include few points.
  • Make sure you have installed .Net 3.5 SP1, if not then download it from here Download .Net 3.5 SP1 and install it.
  • Now follow below steps, once you are done then just change the version of Web Extension from 1.0.61025.0 to 3.5.0.0, find Version=1.0.61025.0 and replace it with Version=3.5.0.0
---------------------- For AJAX Settings in SharePoint web.config------------------------

Open SharePoint web.config from file Location > > C:\Inetpub\wwwroot\wss\VirtualDirectories\80

Extending SharePoint web.config files with ASP.NET AJAX requires that you interleave some Ajax registration entries in-line

with WSS registration entries. To do this you will need to edit your SharePoint web.config file, typically in a directory

like c:\inetpub\wwwroot\wss\virtualdirectories\80.


1. Add a < sectionGroup > element to the < configSections > tag:

< configSections >
< sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup,

System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" >
< sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions,

Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" >
< section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection,

System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"

allowDefinition="MachineToApplication"/ >
< sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup,

System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" >
< section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection,

System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"

allowDefinition="Everywhere" / >
< section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection,

System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"

allowDefinition="MachineToApplication" / >
< section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection,

System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"

allowDefinition="MachineToApplication" / >
< /sectionGroup >
< /sectionGroup >
< /sectionGroup >
< /configSections >



2. Add a < controls > section as a child of the < system.web > / < pages > tag.

< pages >
< controls >
< add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0,

Culture=neutral, PublicKeyToken=31bf3856ad364e35"/ >
< add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/ >

< /controls >
< /pages >


3. Add the following tag to the < assemblies > tag, within < compilation > :

< assemblies >

< add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/ >

assemblies >


4. Add some new registrations to the end of the < httpHandlers > section:


< httpHandlers >
< add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory,

System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/ >
< add verb="*" path="*_AppService.axd" validate="false"

type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35"/ >
< add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler,

System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/ >
< /httpHandlers >


5. Add a new registration to the HttpModules section, beneath any existing registrations.


< httpModules >
< add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35"/ >
< /httpModules >


6. Add a SafeControl entry for the System.Web.UI namespace from Microsoft Ajax Extensions, within the < SharePoint > / < SafeControls > section:

< SafeControls >
< SafeControl Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Namespace="System.Web.UI" TypeName="*" Safe="True" / >
< /SafeControls >


7. Finally, add the following configuration tags at the bottom of web.config, near the bottom before the end < configuration > tag.

< system.web.extensions >
< scripting >
< webServices >
< !-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -- >
< !--
< authenticationService enabled="true" requireSSL = "true|false"/ >
-- >
< !-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved and modified in ASP.NET

AJAX applications, you need to add each property name to the readAccessProperties and writeAccessProperties attributes. -- >
< !--
< profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" / >
-- >
< /webServices >
< !--
< scriptResourceHandler enableCompression="true" enableCaching="true" / >
-- >
< /scripting >
< /system.web.extensions >
< system.webServer >
< validation validateIntegratedModeConfiguration="false"/ >
< modules >
< add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions,

Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/ >
< /modules >
< handlers >
< remove name="WebServiceHandlerFactory-Integrated" / >
< add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35"/ >
< add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"

type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35"/ >
< add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd"

type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35" / >
< /handlers >
< /system.webServer >


Thats all you are done !!!. Now you can add script manager in you page and start using AJAX control tools.

Should you have any question ???, leave a comment