AsyncPostBackTrigger 和 AsyncPostBackTrigger 有什么区别?回发触发?
AsyncPostBackTrigger 和 AsyncPostBackTrigger 有什么区别?回发触发?
What is the difference between AsyncPostBackTrigger & PostBackTrigger?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
默认情况下,UpdatePanel 内部的控件会导致部分页面更新,外部的控件会导致回发,使用这些触发器可以根据需要更改此行为。
来自 http://seminaarit.codezone.fi /video/devdays-2007/track1/2/2-ASP-dotNET_AJAX_Extensions.ppt:(死链接)
Controls inside an UpdatePanel by default cause a partial page update, controls outside cause a postback, using these triggers it is possible to change this behaviour as required.
From http://seminaarit.codezone.fi/video/devdays-2007/track1/2/2-ASP-dotNET_AJAX_Extensions.ppt: (dead link)
这是一篇博客文章,解释了其中的差异:
Here's a blog post which explains the difference:
1. AsyncPostBackTrigger
它是强制页面异步回发的触发器,即 AJAX 方式。数据将在没有完整回发的情况下进行处理。当您使用登录等功能时,您可能会用到这个。
前任。您有两个下拉菜单,即国家/地区和州。选择国家/地区时应加载各州,并应在国家/地区更改时进行更改。
在这种情况下,您可以使用 AsyncPostBackTrigger,它将填充状态 ddl,而无需完全回发。
2. PostBackTrigger
它不遵循 AJAX 功能,而是像往常一样进行完整的回发(不使用 UpdatePanel)。在某些情况下,您可能不希望强制执行部分回发(如上面第 1 点所述)。
就像您在 UpdatePanel 中使用
FileUpload Control
一样,当您通过 AsyncPostBack 执行此操作时,您将不会向服务器获取任何值。它需要完整回发。在这种情况下,您应该使用此触发器。1. AsyncPostBackTrigger
it is the one which enforces Asynchonous post back of the Page.., i.e. the AJAX way. The data will be transacted without full post back. When you are using functionalities like login, you may use this.
Ex. You are having two dropDowns Viz., Countries and States. the states should be loaded when a country is selected and it should be changed on Countries change.
You may use AsyncPostBackTrigger in this scenario, which will populate the states ddl without full post back.
2. PostBackTrigger
It is the one which does not follow the AJAX functionalities, but the full post back as usually(as without using UpdatePanel). Situtions are there where you would not like to enforce Partial Post back (as explained in Point 1. above).
Like you are having
FileUpload Control
withing the UpdatePanel and when you do it by AsyncPostBack, you will not get any values to the server. It requires Full PostBack. in such a case you should use this trigger.假设 Button1 位于更新面板内部,而 Button2 位于更新面板外部。
现在让我们了解更新面板外部的控件正在执行异步回发,而内部的控件则创建同步回发。
因此,由于两个按钮都位于“更新”面板内部的表单“Button1”上,而“bUtton2”位于其外部。
因此,顺便说一下,通过将 Button2 的 ID 及其事件名称提供给示例中给出的 Asyncpostback 触发器,我们假设现在它将像 Button1 一样使用 updatepanel 创建同步回发。
Suppose Button1 is inside your Update panel and Button2 is outside the update panel.
Now let's undertsand that the controls that are outside the update panel are doing a Asyncpostback and that are inside creates a Syncpostback.
So as both buttons are on a form Button1 in inside Update panel and bUtton2 is outside it.
So by the way by giving the Button2's ID and its Event name to the Asyncpostback Trigger as given in the example we suppose that now it will create a syncpostback with the updatepanel as like the Button1.