简体   繁体   中英

What is the difference between IsPostBack, IsAsync and IsCallback?

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:

  1. IsPostBack is true when the page is posted via a form method, I agree 100% .
  2. IsCallBack is true when the page has been called back from an AJAX call, Then for what purpose IsAsync is for?
    from MSDN " IsCallBack : Gets a value that indicates whether the page request is the result of a callback."
  3. IsAsync when an ASP.net AJAX partial update is made ,its an Asynchronous postback.

However I still have some questions:

  1. What is a callback and how it is different from a postback.
  2. Clearly differentiate among IsPostBack, IsAsync and IsCallback.
  3. Currently I'm working on a WebApp, which can perform postBack through jQuery Ajax. So to identify the jQuery Ajax I should use IsPostBack.

Useful links:

Difference between IsCallback and IsPostback

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM