What is the difference between IsPostBack, IsAsync and IsCallback?
Asked Answered
A

1

5

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

Affirmation answered 22/5, 2012 at 20:52 Comment(0)
H
9

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.

Heptamerous answered 22/5, 2012 at 21:16 Comment(2)
How does <ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack> relate to <Page.IsAsync>?Ist
It doesn't, they are independent and are used to check non related features. You can think of Page.IsAsync as information on how the page is processed on the server independently of the type of client request that triggered the page processing.Suture

© 2022 - 2024 — McMap. All rights reserved.