Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

How to Check if the Page was a partial PostBack

0.00/5 (No votes)
13 Oct 2013 1  
While developing ASP.NET 2.0 application with AJAX  many times we came across scenarios when we had to know if the call made to the server is

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

While developing ASP.NET 2.0 application with AJAX many times we came across scenarios when we had to know if the call made to the server is complete postback or partial postback (using update panel)

In ASP.NET 2.0 a property called IsCallBack was exposed for the user to validate this. However it was found that this property is always set to false when used along with ASP.NET AJAX extensions.

In case a partial postback is done using update panel you will find the IsPostBack is always true and IsCallback is always false.

Hence to check whether the page was called using update panel or it was a complete postback we can use the below code.

if (ScriptManager.GetCurrent(this).IsInAsyncPostBack)         
{          
    // Do something only when the page is partially posted back         
}

The ScriptManager.GetCurrent(this).IsInAsyncPostBack returns true when the server side code is invoked using a update panel.

Where this is the instance of the page to which the postback was made.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here