Ajax updatepanel SharePoint 2007

22. March 2010 08:37 by arnoldbo in SharePoint  //  Tags: , ,   //   Comments

At a customer place we had issue’s after deploying a page with an Ajax updatepanel, on the development en test environment everything worked fine but on the customer’s acceptance and production environment the first postback in the updatepanel worked but after that the updatepanel didn’t react anymore.

After my collegue and I found the blog post of Mike Ammerlaan we could solve the problem pretty fast.

from Mike Ammerlaan’s Blog:

Using UpdatePanels within SharePoint

UpdatePanels are a very useful addition to ASP.NET AJAX, and represent the simplest way to convert existing, standard ASP.NET controls and parts to take advantage of Ajax techniques.  However, there are some changes within Windows SharePoint Services which may get in the way of working with ASP.NET AJAX.

Windows SharePoint Services JavaScript has a “form onSubmit wrapper” which is used to override the default form action.  This work is put in place to ensure that certain types of URLs, which may contain double byte characters, will fully work across most postback and asynchronous callback scenarios.  However, if your scenarios do not involve double byte character URLs, you may successful disable this workaround and gain the ability to use ASP.NET AJAX UpdatePanels.

For the page’s were we needed the updatepanel we placed the following script:

<script type="text/javascript"> <!-- // Every single time the page loads, including every single AJAX partial postback function pageLoad() {
        _spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper = true }
--> </script> 

Most important of this script is that the fix needs to be applied after every pageload, otherwise only the first postback works fine.