Page.IsPostBack 和 Page.IsCallBack 有什么区别? [英] What is the difference between Page.IsPostBack and Page.IsCallBack?
问题描述
我最近遇到了一些检查 Page.IsCallBack
的代码,但我不确定它与 Page.IsPostBack
有何不同.谁能给我指点一下?
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?
推荐答案
Page.IsCallBack
它正在获取一个值,该值指示页面请求是否是回调的结果.它是一个特殊的回发,所以总是会发生往返;但是,与经典回发不同,脚本回调不会重绘整个页面.ViewState 不会在回调期间更新,而是用于回发.
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
检查页面是否是第一次访问服务器.与 IsCallBack 不同的是,更新了 ViewState
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
编辑 - 回答您的新问题
Page.IsPostback 属性将为两种请求类型返回 true.只有当请求是客户端回调时,Page.IsCallback 属性才会返回 true
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
这篇关于Page.IsPostBack 和 Page.IsCallBack 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!