Thursday, January 10, 2008

SharePoint 2007, AJAX and web parts

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:

 

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.

 

Other resources:

 

1 comment:

  1. Are there any plans to support the ModalPopupExtender. Currently, it wont work without the correct DOCTYPE, but when you apply it, the formatting goes crazy since SharePoint uses Quirks Mode

    ReplyDelete