Add trigger to UpdatePanel programmatically

Posted on 16th Feb 2014 by admin

Hi,I'm working on a website which uses AJAX and Masterpages. What I have is an AJAX UpdatePanel which contains the ContentPlaceHolder on the MasterPage.However, on one page I have a FileUpload control, which means I have to add the Submit button as a Postback trigger to the UpdatePanel, otherwise the file upload will not work. I've tried doing this both from the MasterPage code file and the Page code file itself without any luck...The code from my masterpage attempt: If Page.Request.RawUrl.Contains("UploadPage.aspx") Then
Dim trigger As UpdatePanelControlTrigger = New PostBackTrigger()
Dim s As Button = page.FindControl("submitBut")
trigger.ControlID = s.ID
up.Triggers.Add(trigger)
End IfWhere up is the id for the update panel.I get an error message saying: A control with ID 'submitBut' could not be found for the trigger in UpdatePanel 'up'.Any help would be greatly appreciated.Thanks in advance
Filed under: updatepanel add trigger programmatically

Other forums