1

I am using DNN6 and i creted two modules and tried to connect between them using module communicator, here is my code:


#region IntermoduleCommunication
ModuleCommunicationEventArgs oArgs = new ModuleCommunicationEventArgs();
oArgs.Value = Session["ShoppingCart"];
if (ModuleCommunication != null)
 ModuleCommunication(this, oArgs);
#endregion

but i am getting 'null' in the ModuleCommunication variable?

Prashant Lakhlani
  • 5,758
  • 5
  • 25
  • 39
ranjenanil
  • 308
  • 2
  • 7
  • 19

4 Answers4

1

Are you wrapping the modules in an update panel, (have the supports partial rendering option enabled) in the DNN manifest?

If I recall correctly, IMC won't work via UpdatePanels.

Chris Hammond
  • 8,873
  • 1
  • 26
  • 34
  • Chris, I am passing the value successfully from one module to the other, however I the Label does not get updated with the text on the View.ascx. How can I force to view it? – alwaysVBNET Apr 19 '16 at 17:24
1

From whatever code you have provided, it should work. In order to get help you need to provide code for both IModuleCommunicator and IModuleListener implementation. But you can review Example implementation here. Let me know if you need more help.

Also if you are not using latest version of dnn, please try testing it by creating of latest dnn instance. Let me know if you need more help.

Prashant Lakhlani
  • 5,758
  • 5
  • 25
  • 39
1

To get this working you need to implement the IModuleCommunicator interface. Right click on the IModuleCommunicator as showed below and extract the interface.

public partial class MyClass: PortalModuleBase, IModuleCommunicator

once extracted the following will be generated

 public event ModuleCommunicationEventHandler ModuleCommunication;

I call it from a button click event

protected void btn1_Click(Object sender, EventArgs e)
        {
    if (ModuleCommunication == null) return;

                ModuleCommunicationEventArgs args = new ModuleCommunicationEventArgs();
                args.Sender = this.GetType().ToString(); ;
                args.Target = "MyTarget";

}

wrap the whole thing in a try catch block to catch exceptions......hope this helps

0

The answer here is simple, you've forgotten exactly how events work, they are just like any other object, you have to instantiate them. aka.

public event ModuleCommunicationEventHandler ModuleCommunication = new ModuleCommunicationEventHandler(SomeStaticMethodThatWillBeCalledByDefault);
Orvid King
  • 1,188
  • 10
  • 16