Search code examples
design-patternseventsuser-controlsobserver-pattern

Generic Obeserver Pattern for User Controls


I want to implement a generic Observer Pattern for user controls. What is the best way to do this?

There are 3 usercontrols: A, B & C. Each of these usercontrols is a representation of a set of data. Each control has a select for display mode (basic or detailed). The site visitore gets to choose which mode. On changing the display mode on any one of the controls, the other controls should reflect that change.

The killer here is that the usercontrols can be addded dynamically to a page by the site visitor and as such the page may have any combination of controls including none of them. They may also feature on multiple aspx pages.

I was thinking the Observer Pattern is the best approach, is it? and if so are there any exmples on teh best way to achieve this?

Thanks, Richard


Solution

  • On changing the display mode on any one of the controls, the other controls should reflect that change.

    Why not have a single setting on a page? Why multiply the same setting in all controls?

    You may be interested in looking at DropThings. Its author has also written a book explaining how he did it. Building a Web 2.0 Portal with ASP.NET 3.5

    Building a Web 2.0 Portal with ASP.NET 3.5