What is the difference between AsyncPostBackTrigger & PostBackTrigger?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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 backPostBackTrigger
- Lets controls inside UpdatePanel post back. * Typically used to
allow certain controls to post back when ChildrenAsTriggers=”true”
Method 2
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.
Method 3
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.
Method 4
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0