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?
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.
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.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With