Welcome to MSDN Blogs Sign in | Join | Help

SYSK 354: How To Determine If The Page_Load Event Is Triggered by a Standard Page Postback or by the UpdatePanel?

Ok, so you’re in a Page_Load code block, and the this.Page.IsPostBack returns true.  How do you know if the request is due to a “standard” page postback or as a result of an UpdatePanel triggered postback resulting in a partial page update?

 

The answer is simple:  when the postback is caused by a trigger for the UpdatePanel control or when you explicitly call the UpdatePanel control's Update() method, the this.ScriptManager1.IsInAsyncPostBack property will return true; whereas during a “normal” postback that value will be false.

 

Note:  in both cases the this.Page.IsAsync will be false.

 

 

Published Thursday, July 12, 2007 9:53 AM by irenak
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# SYSK 354: How To Determine If The Page_Load Event Is Triggered by a Standard Page Postback or by the UpdatePanel?

Thursday, July 12, 2007 1:48 PM by Noticias externas

Ok, so you’re in a Page_Load code block, and the this.Page.IsPostBack returns true . How do you know

# re: SYSK 354: How To Determine If The Page_Load Event Is Triggered by a Standard Page Postback or by the UpdatePanel?

Thursday, July 12, 2007 11:58 PM by Robert McLaws

This is a great tip, but how do you find that out from a UserControl when you're using a ScriptManagerProxy?

# re: SYSK 354: How To Determine If The Page_Load Event Is Triggered by a Standard Page Postback or by the UpdatePanel?

Sunday, April 13, 2008 7:48 PM by Roboblob

Here is how to do it in UserControl even if you are using ScriptManagerProxy:

   protected void Page_Load(object sender, EventArgs e)

   {

       if (Page.IsPostBack)

       {

           // get a reference to ScriptManager and check if we have a partial postback

           if (ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack)

           {

               // partial (asynchronous) postback occured

           }

           else

           {

               // regular full page postback occured

           }

       }

   }

hope it helps...

# re: SYSK 354: How To Determine If The Page_Load Event Is Triggered by a Standard Page Postback or by the UpdatePanel?

Tuesday, January 13, 2009 8:18 PM by SanjayU

Thank you, this is very helpful.

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker