Hi,
you're right, my code works only for refreshed panel fired with a trigger. This code would work in many case :
96 public static UpdatePanel FindRefreshedUpdatePanel(ScriptManager sc)
97 {
98 Control control = sc.Page.FindControl(sc.AsyncPostBackSourceElementID);
99 while (control != null)
100 {
101 if (control is UpdatePanel)
102 return (UpdatePanel)control;
103
104 control = control.NamingContainer;
105 }
106
107 return FindRefreshedUpdatePanelRecursive(control.Page, sc);
108 }
109
110 private static UpdatePanel FindRefreshedUpdatePanelRecursive(Control parent, ScriptManager sc)
111 {
112
113 foreach (Control child in parent.Controls)
114 {
115 if (child is UpdatePanel)
116 {
117 foreach (UpdatePanelTrigger trigger in ((UpdatePanel)child).Triggers)
118 {
119 String ControlID;
120 if (trigger is AsyncPostBackTrigger)
121 ControlID = ((AsyncPostBackTrigger)trigger).ControlID;
122 else if (trigger is PostBackTrigger)
123 ControlID = ((PostBackTrigger)trigger).ControlID;
124 else
125 continue;
126
127 if (child.NamingContainer.FindControl(ControlID).UniqueID == sc.AsyncPostBackSourceElementID)
128 return (UpdatePanel)child;
129 }
130 }
131 UpdatePanel c = FindRefreshedUpdatePanelRecursive(child, sc);
132 if (c != null)
133 {
134 return c;
135 }
136 }
137 return null;
138 }
But I think in some complex case it would not works. For example if we use UserControl, nested UpdatePanel and things like that ... I will have a look at this tommorow.
ewlloyd > I don't try your code but it will not work, if (apt.ControlID == elemID) apt.ControlID is only the ID of the client and elemID is the UniqueID ... so if you use UserControl or MasterPage it will not work because the ControlID is different to UniqueID :-)