2012-06-12 64 views
1

我使用DNN6和我creted两个模块,并试图用模块沟通它们之间的连接不工作,这是我的代码:模块通讯在DNN


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

,但我在ModuleCommunication越来越“空”变量?

回答

1

是否将模块包装在DNN清单中的更新面板中(启用了支持部分渲染选项)?

如果我没有记错,IMC将无法通过UpdatePanels工作。

+0

克里斯,我从一个模块成功地将值传递给另一个,但我标签d oes没有得到View.ascx文本的更新。我该如何强制查看它? – alwaysVBNET

1

从你提供的任何代码,它应该工作。为了获得帮助,您需要为IModuleCommunicatorIModuleListener实施提供代码。但你可以review Example implementation here。让我知道你是否需要更多帮助。

此外,如果您不使用最新版本的dnn,请尝试通过创建最新的dnn实例来测试它。让我知道你是否需要更多帮助。

1

答案在这里很简单,你已经完全忘记了事件是如何工作的,它们就像任何其他对象一样,你必须实例化它们。又名。

public event ModuleCommunicationEventHandler ModuleCommunication = new ModuleCommunicationEventHandler(SomeStaticMethodThatWillBeCalledByDefault); 
1

为了得到这个工作,你需要实现IModuleCommunicator接口。右键单击IModuleCommunicator,如下所示并提取界面。

public partial class MyClass: PortalModuleBase, IModuleCommunicator 

一次提取下面会产生

public event ModuleCommunicationEventHandler ModuleCommunication; 

我把它从一个按钮单击事件

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

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

} 

包住整个事情在try catch块捕获异常.. ....希望这可以帮助