【问题标题】:module communication not working in DNN模块通信在 DNN 中不起作用
【发布时间】:2012-06-12 14:21:59
【问题描述】:

我正在使用 DNN6,我创建了两个模块并尝试使用模块通信器在它们之间进行连接,这是我的代码:


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

但我在 ModuleCommunication 变量中得到“null”?

【问题讨论】:

    标签: c# .net dotnetnuke


    【解决方案1】:

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

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

    【讨论】:

    • 克里斯,我成功地将值从一个模块传递到另一个模块,但是我的标签没有使用 View.ascx 上的文本进行更新。如何强制查看?
    【解决方案2】:

    无论您提供什么代码,它都应该可以工作。为了获得帮助,您需要为 IModuleCommunicatorIModuleListener 实现提供代码。但是你可以review Example implementation here。如果您需要更多帮助,请告诉我。

    另外,如果您没有使用最新版本的 dnn,请尝试通过创建最新的 dnn 实例来测试它。如果您需要更多帮助,请告诉我。

    【讨论】:

      【解决方案3】:

      要实现此功能,您需要实现 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 块中以捕获异常......希望这会有所帮助

      【讨论】:

        【解决方案4】:

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

        public event ModuleCommunicationEventHandler ModuleCommunication = new ModuleCommunicationEventHandler(SomeStaticMethodThatWillBeCalledByDefault);
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-10-01
          • 2011-10-28
          • 1970-01-01
          • 2019-11-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多