What is the difference between AsyncPostBackTrigger & PostBackTrigger?

后端 未结 4 1723
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 05:07

What is the difference between AsyncPostBackTrigger & PostBackTrigger?

相关标签:
4条回答
  • 2020-12-03 05:23

    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.

    0 讨论(0)
  • 2020-12-03 05:28

    Here's a blog post which explains the difference:

    In the template in an update panel, there are the options of an AsyncPostBackTrigger or a PostBackTrigger.

    By default, controls outside of an update panel will trigger a normal synchronous post back. The AsyncPostBackTrigger “wires” up these controls to trigger an asynchronous post back. Conversely, controls declared inside an update panel will trigger an asynchronous call by default. The PostBackTrigger short circuits this, and forces the control to do a synchronous post back.

    0 讨论(0)
  • 2020-12-03 05:45

    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.

    0 讨论(0)
  • 2020-12-03 05:46

    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)

    AsyncPostBackTrigger

    • Converts postbacks into async callbacks * Typically used to trigger updates when controls outside an UpdatePanel post back * If ChildrenAsTriggers="false", can be used to specify which controls inside UpdatePanel should call back rather than post back

    PostBackTrigger

    • Lets controls inside UpdatePanel post back. * Typically used to allow certain controls to post back when ChildrenAsTriggers="true"
    0 讨论(0)
提交回复
热议问题