Telerik RadGrid not using AJAX in SharePoint Application Page

October 15, 2009

I have a SharePoint application page (A page that resides in _layouts and inherits from Microsoft.SharePoint.WebControls.LayoutsPageBase) Where I have a Telerik RadGrid. I have Ajaxified the grid by using a Telerik RadAjaxManager however whenever I filter or page the grid it performs a full page postback rather than an ajax callback. 

I managed to get this working by following the instructions here:
http://www.telerik.com/community/forums/aspnet/ajax/radajaxmanager-sharepoint-2007-bug.aspx#605189

It appears it is the UpdatePanel functionality of AJAX that doesn’t play out of the box with WSS:

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.

 taken from http://blogs.msdn.com/sharepoint/archive/2007/03/02/integrating-asp-net-ajax-with-sharepoint.aspx

So the code I have added to my SharePoint Application Page is:

protected override void CreateChildControls()
{
      base.CreateChildControls();
      this.EnsureUpdatePanelFixups();
}

private void EnsureUpdatePanelFixups()
{
     ScriptManager.RegisterStartupScript(this, typeof(XXXXYourApplicationPageClassXXXXX), “UpdatePanelFixup”, “_spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper=true;”, true);
}

Note: This works for Application Pages only. If you are building a WebPart and having the same issue then the fix for this is mentioned in the links below.

Other useful resources:
http://www.telerik.com/community/forums/aspnet-ajax/ajax/ajax-controls-in-sharepoint-application-page-causing-postbacks.aspx
http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3
http://www.marten-online.com/sharepoint/ajax-second-postback-not-working-in-sharepoint-in-updatepanel.html

Advertisements