User1439367969 posted
The control I was working on has since been greatly changed, leading me to be unable to repeat that specific bug. However I am still seeing the issue.
I've created a simple website (VS2008, Targeting .net 3.5), added the CSSFriendly dll and browser file. To the default page I've added a user control. The user control contains a simple TreeView within a Panel (for the purpose of this bug the panel
is just a container). The TreeView has a OnAdaptedSelectedNodeChanged event which updates a label with the current time. This does not work as expected. My guess at this point is that the WebControlAdapterExtender.RaiseAdaptedEvent method doesn't not support
user controls which contain a heirachy of elements.
In order to prove this theory I added a quickly hashed together bit of code to the RaiseAdapterEvent method:
1 MethodInfo method = methodOwner.GetType().GetMethod(delegateName);
2 if (method == null)
3 {
4 Control parentUserControl = FindParentUserControl(AdaptedControl.Parent);
5 if (parentUserControl != null)
6 {
7 methodOwner = parentUserControl;
8 method = methodOwner.GetType().GetMethod(delegateName);
9 }
10 }
11 if (method == null)
Lines 1 and 11 in the above snippet are pre-existing. I also added the following method:
1 private Control FindParentUserControl(Control control)
2 {
3 if (control.Parent == null)
4 return null;
5 if (control.Parent is UserControl)
6 return control.Parent;
7 return FindParentUserControl(control.Parent);
8 }
Everything started to work as expected, including my original solution.
It would be great to see a more suitable fix in the next change set.