Dotnetnuke模块通讯问题

发布于 2024-12-01 06:04:03 字数 283 浏览 0 评论 0原文

我的 dnn 模块通信有问题。我有一个模块,它实现了侦听器和发送器的模块通信接口。在此模块中,我有一个占位符,用于加载新的 ascx 控件。问题是当我想从这个新的动态加载的控件进行通信时。在此控件中,我还实现了模块通信接口(侦听器和发送器)。但是当我调用发送者方法时,在这个动态加载的控件中更新其他模块(在同一页面上)什么也没有发生。但是然后我从动态加载的控件容器控件(我有占位符的控件)调用“发送者”,它可以更新同一页面上的其他模块。这表明模块通信根本无法在动态加载的 ascx 控件中工作。 有没有人有任何想法来解决这个问题 /theonealf

I have a problem with the dnn module communication. I have a module that implements the module communication interface both listener and sender. in this module, I have a placeholder where I load a new ascx control. the problem is when I want to Communicate from this new dynamically loaded control. In this control i also implemented module communication interfaces( listener and sender). but when I call sender method, in this dynamic loaded control to update an other module (on same page)nothing happens. But then i call a " sender " from the dynamic loaded controls container control( the control where i have the placeholder) it works updating the other module on the same page. It seams that module comunications do not work in dynamic loaded ascx controls at all.
Is there anyone who have any idea , to solve this
/theonealf

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甜中书 2024-12-08 06:04:03

我猜这是一个时间问题。尝试在 Init 事件中加载动态控件,并查看它是否会捕获正在发送的通信。

I would guess that it's a timing issue. Try loading your dynamic control in the Init event, and see if it will catch the communication being sent.

稚气少女 2024-12-08 06:04:03

同意@bdukes,另外还有一些我建议检查的事情:

  1. 在没有任何反应的情况下检查是否有任何异常
  2. 您的控件是否继承自PortalModuleBase?如果您想使用 moduleId、UserInfo、PortalId 或任何其他 dnn 特定对象,则需要这样做。

可能还有其他检查,但这取决于您通过尝试上述内容和@bdukes 建议得到的答案。

Agree with @bdukes, Also there are additional things that I would recommend to check:

  1. Check if there is any exception while nothing happens
  2. Does your control inherits from PortalModuleBase? This will be required if you want to use moduleId, UserInfo, PortalId or any other dnn specific objects.

There can be other checks but it depends on your answer by trying above and @bdukes suggestion.

作业与我同在 2024-12-08 06:04:03

老实说,我在通信接口方面取得的成功有限。如果您能根据自己的需要开始工作,那就太好了。如果您发现需要另一种解决方案,这就是我所做的:

如果我正确理解了问题,那么您关心的是一个模块在加载页面期间需要与另一个模块通信的特定用例。如果是这样,您很可能有一个需要通信的模块,以及一个或多个需要接收该通信的模块。

我将 Context.Items 与 ASP.NET 生命周期结合使用来解决这个问题。 Items 集合只是一个袋子,任何东西都可以塞进去或拉出来。需要通信的模块可以在Page_Load期间将东西放入该项目包中:

var item = "My Thing";
Context.Items.Add("MyThingKey", item);

需要消耗该东西的模块可以在PreRender期间从该包中取出东西。

var item = Context.Items["MyThingKey"].ToString();

关键是在 PreRender 期间执行此操作。这样,您就可以确保通信的消费发生在通信的产生之后。

祝你好运!

Honestly, I have had limited success with the communications interface. If you can get to work for your needs, then excellent. In case you find you need another solution, here's what I've done:

If I understand the question correctly, you're concerned with the specific use-case where one module needs to communicate with another module during the loading of a page. If that is so, you most likely have one module which is the one that needs to communicate, and one or more modules which need to pick up that communication.

I've used Context.Items in combination with the ASP.NET life cycle to solve this problem. The Items collection is just a bag that anything can be stuffed into or pulled out of. The module that needs to communicate can put things into that item bag during Page_Load:

var item = "My Thing";
Context.Items.Add("MyThingKey", item);

The modules which need to consume that thing can pull things out of that bag during PreRender.

var item = Context.Items["MyThingKey"].ToString();

The key is doing this during PreRender. This way, you are assured that the consuming of the communication happens after the production of the communication.

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文