开发者

Adding DNN module error when control has key assigned

I'm creating a module and I was able to add a user control as a view type and everything worked. I want to add a second control, also as a view type, but that's where trouble begins.

If I just add the new control to the module definition, it displays only that control and not both. If I remove it, the original control displays fine. Going back into the module definitions, I went to the module controls and assigned values to the respective Key properties. When I save, my module disappears from the page it was displayed on. If I try to add it again, I get "Object reference not set to an instance of an object."

It was through trial and error I discovered if I remove the key, I can re-add the module it works again (at least as described ab开发者_Go百科ove).

Essentially I want multiple views for my module where individual views can be displayed on different pages (much like the Blog module). I'm not creating a package for distribution so I'm almost to the point of just creating a separate module, but where's the learning experience in that?

I've searched for a tutorial on creating a module with multiple views with no luck. Can anyone provide some insight?


I got round this issue by using the modulesettings to choose which display I wanted for that instance, in my case I used the setting to determine which front end was visable and which was not aswell as the backend code.

Another option is to have one view ascx which is a placeholder and inject either ascx view you want based on a modulesetting.

I have used both these methods before and both work well


In DotNetNuke there can only be one 'View' so if you want to make something that displays different views depending on the situation you have to create a Dispatch view. So depending on your module setting like you have, or a URL parameter, cookie, session, something in the primary View gets another user control to display what is needed.

This post talks about it a bit Dispatch View

Sounds like you found a solution that works for you.


Out of the box DotNeNuke also supports using multiple views, however as soon as you switch to a different view the module enters "Isolation Mode", where it becomes the only module visible on the page.

If this behavior would work for you, then you can add multiple controls, the FIRST control you add without a key, the secondary controls you add with a specific key. You can then use NavigateUrl or EditUrl to construct the link to the specific controls.

From an "edit" perspective, the use of this pattern ensures that your users have a consistent environment with only your module. From a View perspective the usage of other patterns is more commonly a "better" choice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜