Topic: How to add a trigger to an UpdatePanel programmatically
Share/Save/Bookmark
Description: This will show you how to add a trigger to an update panel programatically.



Dim myTrigger As New PostBackTrigger
myTrigger.ControlID = myControl.ClientID.ToString()
myUpdatePanel.Triggers.Add(myTrigger)

Example:

Dim myTrigger As New PostBackTrigger
myTrigger.ControlID = btnFinish.ClientID.ToString()
upnlMain.Triggers.Add(myTrigger)


To add a trigger in the markup, you use the following syntax

Note: Setting UpdateMode to "conditional" means that it will only postback it own update panel if there are others on the page.  Also, you must have an UpdatePanel set to "conditional" if you are going to try to update it programmatically


</asp:UpdatePanel ID="upnlMain" runat="server" UpdateMode="conditional">   <ContentTemplate>

      ...Content...

   </ContentTemplate>
   <Triggers>
      <asp:PostBackTrigger ControlID="btnFinish" />
   </Triggers>
</asp:UpdatePanel>