Friday, August 21, 2009

AJAX UpdatePanel and UpdateProgress to show please wait

     While refreshing the AJAX skill today I wrote a simple code to display please wait message while asynchronous postback. I added one Update Panel, one Update Progress panel and a button control and registered button  as Asynchronous Postback Trigger control. I assign my UpdatePanel’s id as AssociatedUpdatePanelID to UpdateProgress panel. I ran the code found that Progress panel is not displayed while async postback, strange !!!! Then I remember few basic points regarding Update Panel and Update Progress which is available on MSDN and found that If we set AssociatedUpdatePanelID to Update Progress panel then we must have to button as inside Update Panel if register button as Async Postback trigger then it will not work. Below is the points (that MSDN Suggests) needs to remember while using UpdateProgress,

The AssociatedUpdatePanelID property has the following effect on UpdateProgress control behavior,

When the AssociatedUpdatePanelID property is not set, the UpdateProgress control is displayed for the following postbacks:

  • Postbacks that originate from inside any UpdatePanel control.
  • Postbacks that originate from controls that are asynchronous triggers for any UpdatePanel control.

When the AssociatedUpdatePanelID property is set to an UpdatePanel control ID, the UpdateProgress control is displayed for postbacks that originate from inside the associated UpdatePanel control.

If the AssociatedUpdatePanelID property is set to a control that does not exist, the UpdateProgress control will never be shown.

You must provide client script to display an UpdateProgress control when a target UpdatePanel control is updated in the following circumstances

  • When a postback from a control is registered as an asynchronous postback trigger for the panel, and there is an UpdateProgress control on the page. However, the AssociatedUpdatePanelID property is not set to the panel's ID.
  • When postbacks from controls are registered as asynchronous postback controls by using the RegisterAsyncPostBackControl method of the ScriptManager control. 

Happy Programming!!!!

No comments: