<div>I have a web site with a master page that has 2 content areas.
</div> <div> </div> <div>In my aspx page, I have some controls in an UpdatePanel. In the 2nd content area I
have a button that takes some values and binds a gridview in the update panel that is in the 1st content area.</div> <div> </div> <div>This
works if I leave the update panels off, but it posts back. If I add the update panel and set a trigger on the button click event I get the error "A control with ID 'btSearch' could not be found for the trigger in UpdatePanel 'UpdatePanel2'." If I move the
button into the 1st content area, then it works. However, I need to have the button in the 2nd content area.</div> <div> </div> <div>It
seems that the update panel can't find the button by ID when it is in a seperate content area.
</div> <div> </div> <div> <div dir=ltr align=left>I
added the following code to my codebehind, but I get the error "A control with ID 'ctl00_cpContext_btSearch' could not be found for the trigger in UpdatePanel 'UpdatePanel2'."
</div> <div dir=ltr align=left> </div> <div dir=ltr align=left> <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR:
black; FONT-FAMILY: Courier New">
17
foreach(UpdatePanelTrigger t
in UpdatePanel2.Triggers)
18 {
19
AsyncPostBackTrigger apt = t as
AsyncPostBackTrigger;
20
if(apt != null && apt.ControlID ==
"btSearch")
21 {
22 apt.ControlID = btSearch.ClientID;
23
break;
24 }
25 }
26 }
I stepped through the code and it correctly finds the trigger and replaces the ID, but the update panel is still complaining that it can't find the control using the new
ID.
ControlID is a string. I was assuming that since "btSearch" didn't work that btSearch.ClientID would, but it didn't.
</div></div></div> <div> </div> <div>Does anyone have an idea on how to fix this? Or am I doing something
wrong?</div> <div> </div> <div> </div>
ormico
Member
17 Points
6 Posts
Can an Update Panel trigger on a control in a different Content area?
Nov 07, 2006 05:21 PM|LINK
15 protected void Page_Load(object sender, EventArgs e)
16 {
17 foreach(UpdatePanelTrigger t in UpdatePanel2.Triggers)
18 {
19 AsyncPostBackTrigger apt = t as AsyncPostBackTrigger;
20 if(apt != null && apt.ControlID == "btSearch")
21 {
22 apt.ControlID = btSearch.ClientID;
23 break;
24 }
25 }
26 }
I stepped through the code and it correctly finds the trigger and replaces the ID, but the update panel is still complaining that it can't find the control using the new ID.
ControlID is a string. I was assuming that since "btSearch" didn't work that btSearch.ClientID would, but it didn't.
</div> </div></div> <div> </div> <div>Does anyone have an idea on how to fix this? Or am I doing something wrong?</div> <div> </div> <div> </div>http://ZacksFiasco.com/