Pergunta

I cannot find any sample/demo of event aggregator implemented in ASP.NET web forms. Almost all of the articles are for Silverlight.

Can you point me to some article, PREFERABLY with working code in ASP.NET web.forms which implement event aggregator pattern.

Simplest example: Two user controls in ASP.net webform, communicating each other with event aggregator pattern.

EDIT

Currently I have an ASP.NET web forms application heavily based on user controls. Container aspx page can host multiple user controls (ascx) which need to communicate in between. For the time being, it is done by events which go through the container page:

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
// Event from UC1 is handled in UC2
        UC1.OnCategoryFilterSelected += new CategoryFilterSelectedHandler(UC2.MethodInUC2);   
// Event from UC1 is handled in in container APSX               page                                                  
              UC1.OnCategoryFilterSelected += new CategoryFilterSelectedHandler     (MethodInContainerPage);   
         }

This is getting out of control :(

Foi útil?

Solução

I am not familiar with the event aggregator pattern, but a solution to your problem may be found in the Model View Presenter pattern. There is a framework to bring Model View Presenter to Web Forms. In the documentation there is an example of 'cross-presenter messaging' which is solved through a message bus and a publish and subscribe model:

http://www.ronaldwidha.net/2010/05/31/a-simple-example-of-the-webformsmvp-cross-presenter-messaging/

Also, source for the project is on Codeplex, if you want to look at the pattern implementation.

Does that help?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top