Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Page.IsPostBack and Page.IsCallBack?

I've recently ran into some code that checks Page.IsCallBack but I wasn't sure how it is different from Page.IsPostBack. Can anyone enlighten me?

Edit: Are they mutually exclusive or can both occur at the same time in a given situation?

like image 757
Joe Phillips Avatar asked Apr 17 '09 15:04

Joe Phillips


People also ask

What is IsCallBack?

2) IsCallBack : “A callback is generally a call for execution of a function after another function has completed.” But if we try to differentiate it from a postback then we can say: It's a call made to the server to receive specific data instead of whole page refresh like a postback.

What does Page IsPostBack do?

IsPostBack is a property of the Asp.Net page that tells whether or not the page is on its initial load or if a user has perform a button on your web page that has caused the page to post back to itself.

When should I use page IsPostBack?

IsPostBack is used to check if the page is responding to a post back event, like clicking a button. So, lets say you have some textboxes for users to change some data and then click a button to submit the data.

What is difference between postback and IsPostBack?

Autopostback - page is posted back to the server automactically based on some events in the control. ispostback- checks whether the page is being loaded in response to a client postback, or if it is being loaded and accessed for the first time. ispostback=true -page is being loaded in response to a client postback.


2 Answers

Page.IsCallBack

It is getting a value indicating whether the page request is the result of a call back. Its a special postback, so a round-trip always occurs; however, unlike the classic postback, the script callback doesn't redraw the whole page. ViewState is not updated during a callback, it is for postback.

Page.IsPostBack

Checks whether the Page is accessing the server for the first time or not. Unlike the IsCallBack, the ViewState is updated

Refer to Page Life Cycle for more detail that shows a diagram illustrating the sequence of events

Edit - To answer your new question

Page.IsPostback property will return true for both request types. The Page.IsCallback property will return true only when the request is a client callback

like image 72
TStamper Avatar answered Oct 04 '22 21:10

TStamper


IsPostBack is true when the page is posted via a form method

IsCallBack is true when the page has been called back from an AJAX call.

like image 28
bendewey Avatar answered Oct 04 '22 22:10

bendewey