MessageNotifer is aimed to decouple the communication between modules in Umbraco CMS. It is also suitable to normal Asp.net Application.

In your code, you can publish you event in the following way by MessageNotifier
MessageNotifer.Instance["eventName"].Notify(this, new NotifierEventArgs{Data = new object()}); 


If you just want to publish an event without passing any data, just set null to the second parameter, as following.
MessageNotifer.Instance["eventName"].Notify(this, null); 


If you want to publish an event with some type of data, just set the "Data" data field of NotiferEventArgs object. The following code passes "Hello" to the event.
MessageNotifer.Instance["eventName"].Notify(this, new NotifierEventArgs{Data = "Hello";


Then in any component that has been loaded in to current AppDomain can subscribe the event as following.
MessageNotifier.Instance["eventName"].Notifer += (s,e)=>{ //your code to repond the event goes here.}; 



In the asp.net usercontrol, it is recommended to subscribe the event in Init().

Supported by Umbraco Development Team of Nova Software

Last edited Jan 29, 2013 at 10:42 PM by czy, version 3

Comments

No comments yet.