SharePoint 2007 and Ajax UpdatePanel Post Back Problem

Working on a recent project I had the need to create a custom calendar control web part.   One of the requirements I had was to make sure that when users navigated the calendar the whole page didn’t post back.    I knew a simple solution, using an UpdatePanel.   I figured this would take me just a few minutes to get the web.config file prepped with the necessary ajax updates and then wrap my calendar control with an UpdatePanel.

Since I am working on a post SP1 version of SharePoint I didn’t need to do any of the javascript hacks to get the UpdatePanel to work.  I should have been able to just wrap the calendar control and be on my way.   However, things did not go as planned.   Everytime I tested the web part the full page would post back instead of just updating the calendar.   What was wrong?

It turns out the answer was a simple one.  I had forgotten to set the ID property of my calendar control.  This made it impossible for the updatepanel to work properly and caused the full page to post back.    Once the ID was in place the updatepanel worked as expected.

0 thoughts on “SharePoint 2007 and Ajax UpdatePanel Post Back Problem”

  1. Hi
    Can you please explain the solution of the ID Property in more
    as i am having an issue with the update panel on SharePoint 2007 SP2 as the ajax request works fine without posting back the page but the content of the update panel stay the same while it works under the development environment (which has Sharepoint services )

    1. I was creating a custom web part that included a calendar control. I wanted the calendar to update when a user clicked on the forward / back buttons without having the whole page refresh. Since I was creating a custom web part I needed to create an instance of all of the controls in the CreateChildControls override for the web part class. I create my calendar control using the normal C# syntax:

      Calendar myCalendar = new Calendar;

      Of course I set some properties and created event handler for some of the calendar events. The issue I ran into was that I had not given the control a unique ID. To resolve the issue I only had to add the following code after creating an instance of the calendar control:

      myCalendar.ID="myCalendar";

      I am not sure if this will resolve your specific issue… but it might be worth trying.

Leave a Reply