The AsyncPostBackTrigger is used in ASP.NET AJAX to, as it states, trigger an asynchronous postback. Adding a trigger to an UpdatePanel is fairly straight forward. You can either do it through the UP's Triggers GUI or within the <asp:UpdatePanel> tag under the <Triggers> tag by adding:
<asp:AsyncPostBackTrigger ControlID="someControl" EventName="Click" />
Adding a trigger through any of the previously mentioned methods works as expected. The problem is when you want to set an AsyncPostBackTrigger on a dynamically generated control, like one within a DataList. You cannot do this through the GUI mode because it will not list the control. Instead you have to programmatically add an AsyncPostBackTrigger.
My issue began when I tried to set a trigger on a LinkButton within a DataList. The LinkButton uses the OnCommand event to pass a CommandArgument. In the DataList_OnItemDataBound I added the appropriate code to wire up the AsyncPostBackTrigger:
// Add postback trigger
AsyncPostBackTrigger ap = new AsyncPostBackTrigger();
ap.ControlID = lnkControl.UniqueID;
ap.EventName = "Command";
upFMV.Triggers.Add(ap);
Now it seems rational that the EventName would be "Command" and that this should work the same way as the previous methods. However after running the code I get no UpdatePanel update! I tried a few other event names but to no avail. After posting a question on forums.asp.net I was told to remove the event name. This actually worked but I'm still not sure why.
My code now looks like:
// Add postback trigger
AsyncPostBackTrigger ap = new AsyncPostBackTrigger();
ap.ControlID = lnkControl.UniqueID;
upFMV.Triggers.Add(ap);
It seems to fire for the correct event too. Even though it works if anyone has any insight to this I would greatly appreciate it! And if you're trying to learn how to use the AsyncPostBackTrigger, well now you've got an example.