As Mike wrote in Using ASP.NET for AJAX in SharePoint Sites - Tread Gently for Now - Ajax works in the RTM release of SharePoint 2007 (both WSS 3.0 and MOSS) but it is not supported . Fortunately when you install Service Pack 1 for WSS 3.0 or MOSS - you will get full AJAX support as described by Joel in ASP.NET AJAX Support in WSS 3.0 and MOSS 2007 SP1 .
Here's a quick rundown of what I did to create my first simple Ajax-enabled web part:
- Install the ASP.NET 2.0 Ajax extensions
- Adapt the web.config as described in Integrating ASP.NET AJAX with SharePoint (Mike Ammerlaan) - to make things easier take a look at the Ajax.Config feature in the Features project on Codeplex - this will do everything for you.
- Create a new site and modify the master page so that it contains a Scriptmanager control (this control manages the client script required for ASP.NET AJAX).
- Write the webpart based on the sample code described in the article of Mike Ammerlaan
Important remark: If you take a look at the example with the UpdatePanel you will also notice that there is some code embedded to make UpdatePanels work correctly.
Adapting the master page is not that nice to do so there actually is a workaround which is described in this posting by Eric - AjaxBasePart : Easy ASP.NET 2.0 Ajax extensions 1.0 and SharePoint Server 2007 (Eric Schoonover). This shows how you can create a base class which will do the ScriptManager insertion as well as add the necessary code for the UpdatePanel fix. Mike however tells that this might cause problems - so I suggest that you test your code thoroughly when doing a dynamic insert of the ScriptManager.
There are a lot of samples out there which show you how to use AJAX - something which I haven't found yet however is information about how you can do AJAX-enabled web part connections. Maybe something for a next posting. You can also expect a posting about how to use the AJAX Control toolkit in SharePoint.
- Using a SPGridview inside an ASP.NET Updatepanel
- Nikhil Kothari Web Development Helper
- AJAX SharePoint list rotator web part
- What we have learned from AJAX code in SharePoint
- ASP.NET AJAX Support in WSS 3.0 and MOSS 2007 SP1
- KB941955 Update for SharePoint 2007 AJAX Web Part Development
- Using a SPGridView inside an ASP.NET AJAX UpdatePanel