Triggering an Update Panel from a control in a different ContentPlaceHolder

I can across an anamoly today when I tried to trigger an Update Panel from a control in a different ContentPlaceHolder.  The IDE recognized the control in the designer as I was able to select the control ID from the dropdown.  But, when I ran the page I received an error stating: "A control with ID 'Button1' could not be found for the trigger in UpdatePanel 'UpdatePanel1'." 

This is something I think should be fixed in the AJAX framework.  The Unique ID of the button is "ctl00$ContentPlaceHolder2$Button1", but the UpdatePanel is in ContentPlaceHolder1 so it assigned the controlID of the trigger to "ctl00$ContentPlaceHolder1$Button1" causing the YSOD ("Yellow Screen of Death").

The work around that I currently use is to dynamically add the trigger to the update panel.

AsyncPostBackTrigger trig = new AsyncPostBackTrigger();
trig.ControlID = Button1.UniqueID; //Unique ID, not client ID
trig.EventName = "Click";
UpdatePanel1.Triggers.Add(trig);

15 Comments

Comments have been disabled for this content.