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)
{
}
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.