ASP.NET control changed events
I have a setup where I have a parent page (P) with two child controls (C1 and C2) and each child control has a sub control (S1 and S2 one belonging to C1 and C2 respectively). When one of the sub controls updates it causes the content of BOTH of the child controls to update; i.e. if S1 is a dropdown and the user changes S1's selected value then C1 and C2 both need to run a (public) method to repopulate themselves.
I am trying to figure out the best way to accomplish this. I know I could do it by having the S1 control bubble an event to P and have P call C1 and C2's update method. I'm wondering if the开发者_如何学Pythonre is a way though that I can have S1 send out an "alert" rather than a bubble event which would go to all controls on the page (not just up the parent tree like bubbling does). Does anybody know if this is possible or should I stick with bubbling?
Perhaps use some variant of the Observer Pattern?
精彩评论