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

早过忘川 提交于 2019-11-27 00:17:02

问题


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?


回答1:


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




回答2:


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.




回答3:


A callback is 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.

More info here:




回答4:


A postback is when the form is posted back to itself, either by clicking a submit button or through Javascript (like AutoPostback controls)

A callback is when an AJAX Control calls a method on the page as part of an ajax request




回答5:


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



来源:https://stackoverflow.com/questions/760912/what-is-the-difference-between-page-ispostback-and-page-iscallback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!