简体   繁体   English

是否可以在不将页面限制为特定模块的情况下呈现DotNetNuke模块的控件?

[英]Can I render a DotNetNuke module's control without restricting the page to a specific module?

I am working on a DotNetNuke module that consists of several different screens, with each having it's own set of user interface interactions. 我正在研究一个由几个不同屏幕组成的DotNetNuke模块,每个屏幕都有自己的一组用户界面交互。 I decided to handle this by putting each screen in a different module control. 我决定通过将每个屏幕放在不同的模块控件中来处理此问题。 The only way I can find to load that control is to give the link a URL via: 我找到加载该控件的唯一方法是通过以下方式为链接提供URL:

Globals.NavigateURL(Constants.LicenseDetailControl, "clientId=" + _clientId, "licenseId=" + data.Id, "mid=" + this.ModuleId);

Unfortunately, this restricts the page to ONLY render this specific module, due to the mid=xxx query parameter. 不幸的是,由于mid=xxx查询参数,这限制了页面仅呈现此特定模块。 However if I do not provide the module ID parameter then my control doesn't render at all and the page is blank. 但是,如果我不提供模块ID参数,则控件根本不会呈现,页面为空白。

Is there any way to render a specific control without forcing the page to only display one module? 有什么方法可以呈现特定的控件,而不必强制页面仅显示一个模块?

Is there any way to render a specific control without forcing the page to only display one module? 有什么方法可以呈现特定的控件,而不必强制页面仅显示一个模块?

No is the answer. 没有答案。

Rending a specific control by specifying the ctl type and the module Id is usually used for editing and admin modules, and they specifically exclude the other modules from the page. 通过指定ctl类型和模块ID来呈现特定控件,通常用于编辑和管理模块,它们专门从页面中排除其他模块。

As Mitchel has answered, you have to do the dynamic loading yourself. 正如Mitchel回答的那样,您必须自己进行动态加载。 There are other modules that do this, you could copy the patterns. 还有其他模块可以执行此操作,您可以复制模式。 A lot of the Ventrian modules use their own Url specifications to load the different controls (which means not using the /ctl/xx and /mid/yy in the Url, but replacing it with your own definition, like 'view=x') 许多Ventrian模块使用它们自己的Url规范来加载不同的控件(这意味着不在Url中使用/ ctl / xx和/ mid / yy,而是将其替换为您自己的定义,例如'view = x')

However, you can also look at spreading your module across different pages, so that one DNN page has a 'list' and another has the 'view'. 但是,您还可以查看将模块分布在不同页面上的情况,以便一个DNN页面具有一个“列表”,而另一个具有“视图”。 This gives a more logical set of Urls (imagine a License list page called /licences and then a licence detail page called /licence/licenceId/xx). 这给出了一组更合乎逻辑的Urls(想象一个名为/ licences的许可列表页面,然后一个名为/ licence / licenceId / xx的许可详细信息页面)。 It also allows for more flexibility in using the module throughout the site. 它还在整个站点中使用该模块时提供了更大的灵活性。 But it does make the install less intuitive because it just dumps all the modules on the one page. 但这确实使安装不太直观,因为它仅将所有模块都转储到一页上。

I wrote a blog post on this topic a while back - trying to explain how it all fits together. 不久前,我写了一篇有关该主题的博客文章-试图解释它们如何融合在一起。 It's older but all still relevant and might give you some more information. 它较旧,但仍然有用,可能会为您提供更多信息。 Designing, Structuring and Architecting DotNetNuke Modules 设计,构建和架构DotNetNuke模块

Or, as another commenter has already posted, just do full AJAX display of the content. 或者,正如另一个评论者已经发布的那样,只需对内容进行完整的AJAX显示。

Well, the answer to this isn't quite as easy as you might hope. 好吧,答案并不像您希望的那么容易。 The situation that you are looking at is what is known as "module isolation" and from a framework perspective there is no real way to get around it. 您正在查看的情况就是所谓的“模块隔离”,从框架的角度来看,没有真正的解决方法。

However you have a few options on how you can do this within your module to get the desired effect. 但是,对于如何在模块中执行此操作以获得所需的效果,您有一些选择。

  1. In your main view control dynamically load the actual view into a PlaceHolder depending on a querystring value that you pass and process. 在主视图控件中,根据您传递和处理的查询字符串值,将实际视图动态加载到PlaceHolder中。
  2. In your main view control have panels for each of the views and show/hide them as needed via a parameter 在主视图控件中,每个视图都有面板,并根据需要通过参数显示/隐藏它们
  3. In your main view control add sub controls for each of the views. 在主视图控件中,为每个视图添加子控件。 From here you can enable/disable items and viewstate as needed to handle the views, again by processing a parameter. 在这里,您可以再次根据需要通过处理参数来启用/禁用项目和viewstate来处理视图。

Personally I go with either 1 or 3. One works well and is the most clean, but I've found that some controls have issues with dynamic injection. 就我个人而言,我选择1或3。一个效果很好,并且最干净,但是我发现某些控件在动态注入方面存在问题。 Option 3 is preferred by me otherwise in that I can disable viewstate on all controls that are not being rendered to reduce page size that would otherwise be bloated by 2. 我更喜欢选项3,因为我可以在所有未呈现的控件上禁用viewstate,以减小页面大小,否则页面大小将增加2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM