I was writing code in Page_Load
and I used IsPostBack
in the first place but then I came across with IsAsync
and IsCallback
properties. I started to think and they look like somewhat the same. From google I found some information:
IsPostBack
is true when the page is posted via a form method, I agree 100% . IsCallBack
is true when the page has been called back from an AJAX call, Then for what purpose IsAsync is for? IsCallBack
: Gets a value that indicates whether the page request is the result of a callback." IsAsync
when an ASP.net AJAX partial update is made ,its an Asynchronous postback. However I still have some questions:
The IsAsync
is independent of the type of request made by the client and its used to identify a page that is processed asynchronously as described in the documentation:
Gets a value indicating whether the page is processed asynchronously.
You can read more about asynchronous pages in this MSDN Magazine article Asynchronous Pages in ASP.NET 2.0 .
The IsCallback
is used to identify a client callback, see Implementing Client Callbacks Programmatically Without Postbacks in ASP.NET Web Pages and finally the IsPostback
identifies a request that resulted from the submission of the form associated with the page. The IsPostback
by itself cannot be used to identify a postback that will fully render the page from one that will do a partial rendering, for example, if you are using an UpdatePanel
.
In order to identify a postback request that will only perform partial rendering you will need to check that IsPostback
is true and ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack
is also true.
Also of interest to this topic How to: Determine How ASP.NET Web Pages Were Invoked .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.