<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>
I have the same problem on one of my pages. I am using Beta 1. I am working around this by setting one of the UpdatePanel's UpdateMode to "Always". I am not sure if this would help on your page. Does anybody know how to correctly reference a control in a
different content area, or if this is a limitation for UpdatePanels?
1. Put your ScriptManager Control on your master page.
2. Do not register your triggers in the <Triggers> section of your update panel, but instead add the following code to your Page.Init event:
If Not Page.IsPostBack Then
Dim trigger As New Microsoft.Web.UI.AsyncPostBackTrigger
trigger.EventName = "Click"
trigger.ControlID = btnSubmit.ClientID.ToString
up1.Triggers.Add(trigger)
End If
btnSubmit is my trigger, but you can substitute whatever trigger you have on your page for this. Also, if you need to add more than one trigger, simply repeat the process in the Page.Init Event.
Please let me know if this works for you. So far, it appears to be working for me...
I tried this, but it does not work. I have a content area with three buttons and another content area with a multiview. Based on the button clicks, I want to show a specific view pane of the multiview. So the code behind each button is just - multiview.setactiveview
- 0 or 1 or 2...
The three buttons are not in update panel, but the multiview is. When I click on the buttons, the page refreshes. Using your method, I don't get the error anymore about "could not be found for the trigger in UpdatePanel", but the page refreshes on every
click. However, if I move the buttons to the multiview content area, then the page does not refresh. I
I think we can no more registering triggers like this in RC :
If Not Page.IsPostBack Then
Dim trigger As New Microsoft.Web.UI.AsyncPostBackTrigger
trigger.EventName = "Click"
trigger.ControlID = btnSubmit.ClientID.ToString
up1.Triggers.Add(trigger)
End If
I have solved my problem by doing the following..Please let me know if there are any negative issues with doing this.
I wrapped my 2 content areas in the master page in a update panel. Basicalle I put the content panes inside an update panel in the master page. Now on my other page, if I click on a button in one content area, both the contents get updated without the page
being refreshed.
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/
bennedik
Member
21 Points
6 Posts
Re: Can an Update Panel trigger on a control in a different Content area?
Nov 08, 2006 09:00 AM|LINK
I have the same problem on one of my pages. I am using Beta 1. I am working around this by setting one of the UpdatePanel's UpdateMode to "Always". I am not sure if this would help on your page. Does anybody know how to correctly reference a control in a different content area, or if this is a limitation for UpdatePanels?
JDG1
Member
45 Points
7 Posts
Re: Can an Update Panel trigger on a control in a different Content area?
Nov 27, 2006 11:48 PM|LINK
I think I have found a solution:
1. Put your ScriptManager Control on your master page.
2. Do not register your triggers in the <Triggers> section of your update panel, but instead add the following code to your Page.Init event:
If Not Page.IsPostBack Then
Dim trigger As New Microsoft.Web.UI.AsyncPostBackTrigger
trigger.EventName = "Click"
trigger.ControlID = btnSubmit.ClientID.ToString
up1.Triggers.Add(trigger)
End If
btnSubmit is my trigger, but you can substitute whatever trigger you have on your page for this. Also, if you need to add more than one trigger, simply repeat the process in the Page.Init Event.
Please let me know if this works for you. So far, it appears to be working for me...
JDG.
ajax update panel MasterPage
JDG1
Member
45 Points
7 Posts
Re: Can an Update Panel trigger on a control in a different Content area?
Nov 27, 2006 11:51 PM|LINK
One more thing. I think it is clear from the above example, but "up1" is my UpdatePanel.
JDG.
JDG1
Member
45 Points
7 Posts
Re: Can an Update Panel trigger on a control in a different Content area?
Nov 28, 2006 02:57 PM|LINK
After some more testing, btnSubmit.UniqueID.ToString appears to work more consistently.
JDG.
marathi
Member
195 Points
76 Posts
Re: Can an Update Panel trigger on a control in a different Content area?
Jan 09, 2007 12:37 PM|LINK
I tried this, but it does not work. I have a content area with three buttons and another content area with a multiview. Based on the button clicks, I want to show a specific view pane of the multiview. So the code behind each button is just - multiview.setactiveview - 0 or 1 or 2...
The three buttons are not in update panel, but the multiview is. When I click on the buttons, the page refreshes. Using your method, I don't get the error anymore about "could not be found for the trigger in UpdatePanel", but the page refreshes on every click. However, if I move the buttons to the multiview content area, then the page does not refresh. I
I would appreciate any help at all.
Thanks
Pluginbaby
Contributor
2961 Points
486 Posts
MVP
Re: Can an Update Panel trigger on a control in a different Content area?
Jan 10, 2007 07:36 PM|LINK
Hi,
I think we can no more registering triggers like this in RC :
If Not Page.IsPostBack Then
Dim trigger As New Microsoft.Web.UI.AsyncPostBackTrigger
trigger.EventName = "Click"
trigger.ControlID = btnSubmit.ClientID.ToString
up1.Triggers.Add(trigger)
End If
Can anyone confirm ?
Try this one instead :
ScriptManager1.RegisterAsyncPostBackControl(yourControl);
Laurent Duveau
MVP / MCT / RD
http://weblogs.asp.net/lduveau/
marathi
Member
195 Points
76 Posts
Re: Can an Update Panel trigger on a control in a different Content area?
Jan 12, 2007 05:32 PM|LINK
How do you do that if the scrip manager is on the master page and the controls are in a content in a page that comes from master page?
Thanks
Pluginbaby
Contributor
2961 Points
486 Posts
MVP
Re: Can an Update Panel trigger on a control in a different Content area?
Jan 12, 2007 07:23 PM|LINK
Hi,
You have to expose your ScriptManager in a public property into your MasterPage codebehind.
Then you can do :
(MainMasterPage)Page.Master).YourProperty.... in your content page.
[But it's better if you have a Base Page as you do not have to cast]
Laurent Duveau
MVP / MCT / RD
http://weblogs.asp.net/lduveau/
marathi
Member
195 Points
76 Posts
Re: Can an Update Panel trigger on a control in a different Content area?
Jan 13, 2007 12:05 AM|LINK
Thanks,
I have solved my problem by doing the following..Please let me know if there are any negative issues with doing this.
I wrapped my 2 content areas in the master page in a update panel. Basicalle I put the content panes inside an update panel in the master page. Now on my other page, if I click on a button in one content area, both the contents get updated without the page being refreshed.
Thanks again.