Dotnetnuke Inter Module Communication

Simple as i could make that seamlessly tough concept about dotnetnuke.

i simply made two dotnetnuke modules 1 to send message to other module (receiver). simply implement two dotnetnuke ready made interfaces and sender raise event and send data in object through eventarguments and receiver get that data through that raised event.

i think enough talks lets code sorry for stupid formatting😛

Sender Steps with example code:

implement class by IModuleCommunicator like below{

Implements Entities.Modules.Communications.IModuleCommunicator}

Create controls and Add like below{

Me.txtMsg1.Text = “Message 2 Send”
Me.btnSend1.Text = “Send”
Me.Controls.Add(txtMsg1)
Me.Controls.Add(btnSend1)}

Declare Event and make created controls eventable{

Public Event ModuleCommunication(ByVal sender As Object, ByVal e As DotNetNuke.Entities.Modules.Communications.ModuleCommunicationEventArgs)

Implements DotNetNuke.Entities.Modules.Communications.IModuleCommunicator.ModuleCommunication
Protected WithEvents txtMsg1 As New System.Web.UI.WebControls.TextBox
Protected WithEvents btnSend1 As New System.Web.UI.WebControls.Button

}

Declare event arguments and raise event like below in btnSend click event{

Dim objEventArgs As New DotNetNuke.Entities.Modules.Communications.

ModuleCommunicationEventArgs(“IMCSender”, Me.txtMsg1.Text,

GetType(ViewIMCSender).Name, “ViewIMCSReceiver”) RaiseEvent ModuleCommunication(Me, objEventArgs)}

Receiver Steps with example code:

Implement class by IModuleListener like below{

Implements DotNetNuke.Entities.Modules.Communications.IModuleListener}

Implement OnModuleCommunication like below{

Select Case e.Type
Case “IMCSender”
If e.Sender = “ViewIMCSender” And e.Target = GetType(YourCompany.Modules.IMCSReceiver.ViewIMCSReceiver).Name Then
lblReceive.Text = e.Value.ToString()
End If End Select }

5 responses to “Dotnetnuke Inter Module Communication

  1. Briana Tarrance

    I believe that I understand the information that is in the quotes, but please elaborate on exactly what is supposed to go in those arguments. I believe this is the last bit I need to understand to get over the hump.

    Thanks

  2. Briana,

    Dnn has no event message filtering, so all the event messages are sent to all the modules implementing the IModuleListener interface. Therefore, reciever modules must find out if they should care about the event message.

    The select case -statement simply ignores all the event messages sent by other than IMCSender classes.

    The if -statement checks that sender is some module we know to send event messages to current module and that the target is declared to be of current module type.

    Take a look on another blog too:

    http://woaychee.wordpress.com/2007/10/16/inter-module-communication-in-dnn-using-c/

    -vP

  3. Muhamad,

    If you can help in any way I really do appreciate. It has been 4 days of searching and Trial and Error.
    I have a Search box Textbox1.text that needs to pass e.value to tbox.text in other module and then GrideView.Databind. I can successfully do this with normal asp.net crosspageposting. I cannot seem to figure how to get the e.value via the listening module then databind. I can however easily make a label.text = e.value and it works, so I know they are talking. Anything you can suggest I would dearly appreciate.

    Jane

  4. I got it. From woaychee site, I converted it to VB.

    If e.Sender = “My Search Module” Then

    Dim imcValue As String = DirectCast(e.Value, String)

    TextBox.Text = imcValue

    GridView1.Databind

    My next task is to find out if there a way to make IMC work with a module that is located on another tab(page)? I prefer my results page not be on the same page. I have tried using Globals.NavigateURL pointing to a result control but the e.value will not pass using this Redirect. Any Ideas?

  5. Hi
    I am new here can any one help me in applying DNN in my website.
    —————————-
    Nina
    The Fastest, Easiest way to learn DotNetNuke! Free Trial Lessons!!
    http://www.applydnn.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s