Paul Juenger a.k.a. PJDev

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";


Ashish said:

This doesnot work for me the UniqueID on the server & the one actually created by ASP.NET are dfferent

# January 6, 2009 4:20 AM

pjdev said:

Ashish - I have this running on a couple of live sites and it is working correctly.  Email me a sample and I'll take a look at what you have.

# January 9, 2009 10:21 AM

Nathan said:

It's worth noting that if you must put this code in the Page_Init() method.

I mistakenly put it in my Page_Load() where it doesn't work, but I didn't actually realize at first because the UpdatePanel being triggered had UpdateMode set to Always, and was being refreshed from another UpdatePanel posting back, instead of the actual trigger firing.

Needless to say I was chasing my tail for a little while there, but now have the UpdatePanel being triggered set to a Conditional UpdateMode, and the triggers assigned programmatically (as above) within the Page_Init() method.

# April 27, 2009 5:58 PM

peter said:

Brilliant, works well for me.

# August 3, 2009 10:21 PM

Yannick said:

Thanks a lot, exactly what I needed :)

# January 29, 2010 4:34 AM

Saber Ahmady said:

You are the best :)

# March 11, 2010 10:56 AM

markand said:

really  u r the great!!!!!!!!!!!

and best.......

# April 2, 2011 2:54 AM

Mario Ancona said:

Great solution it work for my

thanks alot

# February 16, 2012 4:43 PM

Kyle said:

Yeah, it happens sometimes ... Nothing special.

# March 27, 2012 9:34 PM

crork said:

riW5pS Very good article post.Much thanks again. Will read on...

# October 8, 2012 7:05 AM

crork said:

FyXmN8 Thanks-a-mundo for the blog article.Much thanks again. Keep writing.

# October 20, 2012 12:17 PM

noha said:

thank yoooooooooooooooou :)

# October 21, 2012 11:39 AM

cheap seo services said:

yWbbHq Looking forward to reading more. Great blog post.Much thanks again. Really Cool.

# November 8, 2012 3:45 PM

Mike Wilson said:

Brilliant article - thanks for sharing the info. I get up to all sorts of tricks getting controls to trigger actions in update panels - usually using javascript to click a button that is set as the ControlID for a trigger.

On one page I have an update panel with 7 gridviews on tabs. Below it I have a div I show modally that displays data when a linkbutton in the gridviews is clicked.

That code in Page_Init() works beautifully.

# December 19, 2012 11:30 AM

Hargis said:

Hi there! I just would like to give you a huge thumbs up for your excellent information you've got here on this post. I will be returning to your site for more soon.

# April 15, 2013 8:55 PM