How to Check if the Page was a partial PostBack
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.
Revision number 1, Tuesday, March 09, 2010 6:29:06 AM by Binary_Fiddle
This is not the most up to date version of this article. The most recent version can be found here.
You must Login to comment.