Search code examples
c#dotnetnukedotnetnuke-module

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. 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:

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. However if I do not provide the module ID parameter then my control doesn't render at all and the page is blank.

Is there any way to render a specific control without forcing the page to only display one module?


Solution

  • 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.
    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.

    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. 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.