Thursday 23 May 2013

First step to using AJAX in MOSS 2007

The scenario :Using AJAX in SharePoint esp. MOSS 2007 is quite exciting.At the same time developers are unaware of the pain to configure your SharePoint site to be able to use AJAX. I hope this article will give you some space to breathe.

The problem: There are awful lot of blogs over internet ,that very well describe the process to use AJAX in SharePoint 2007.So what is the PROBLEM we're talking about. If, before arriving to this blog you've read any other blogs, many of them ask to perform a handful of changes at specific locations in the web.config of the SharePoint site you wish to enable AJAX. As you know, a slight error in web.config will take your entire site down. I'll try to explain a much easier and moreover a safer approach to make changes in web.config.
Before diving in , lets look at the prerequisites for ASP.NET AJAX.
  • .NET Framework 3.5 - its recommended to have 3.5 ,but if not possible only a dll of Systems.Web.Extensions with version 3.5.0.0 inside GAC will do.
  • Extend web.config of IIS website with ASP.NET extensions.(This is what we'll cover as we go further) 
Visual Studio 2008 comes with AJAX support and a rich AJAX control kit-just in case you want to develop something in AJAX for your SharePoint

The solution: To make changes in web.config so that it supports AJAX functionality perform the following steps:

  • Go to Visual Studio 2008, and create an ASP.NET web site



  • Make sure you have selected .Net Framework 2.0
  • Open the web.config file of the SharePoint site ,you wish to enable AJAX feature
  • Copy its entire content .(I would recommend ,you take a copy of the web.config file before making any changes)
  • Now replace the web.config file contents which came with the ASP.NET web site ,with the copied content from the previous step
  • So now you have the default web.config file for the SharePoint site inside your newly created web site.Save it.
  • Right Click the solution in visual studio , and select property pages at the bottom.
  • Go to Build section and change the Target framework to .Net Framework 3.5

  • Click OK.This will not replace the contents of the web.config ,but will modify it to accommodate all the changes required to support AJAX. 
  • Indirectly it will configure the web.config file as per .Net Framework 3.5
  • Now open the web.config of you ASP.NET web site from the solution explorer and copy all its content.
  • Go to the virtual directory inside inetpub where your web site resides and replace all its content with the just copied ones.
    And thats it..!!!
    You now have AJAX integrated with your SharePoint site.






No comments:

Post a Comment