Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesSetting Container Visibility at Runtime?Setting Container Visibility at Runtime?
Previous
 
Next
New Post
11/29/2011 2:37 PM
 

I'm hoping someone might know a good way to accomplish something.  I have a use case where depending on a number of values I need to hide all the other modules on a page from within a module I'm developing.  Because the visibility requirements are conditional I can't use the /ctrl method but need to set container visibility to false by passing in module ids.

I have a working loop that gets all of the module id on the current tab...but cannot seem to find anything in the framework that allows me to set module or container visibility within this loop.

I'm hoping someone has been here before of can throw me a few breadcrumbs to get me to the right place within the framework.

 Something like the code below is where I'd like to get.  The HideContainerControl method is not working. 

public void HideAllModules()
        {
            ModuleController moduleController = new ModuleController();

            // find all the modules on the page
            Dictionary modules = moduleController.GetTabModules(TabId);
            foreach (ModuleInfo mi in modules.Values)
            {
                HideContainerControl(mi.ModuleID).Visible = false;
            }
        }

        public Control HideContainerControl(int moduleid)
        {
            return FindControl(moduleid.ToString());
        }



Steven Webster
Manager, Community Platform
F5 Networks, DevCentral
 
New Post
12/2/2011 11:39 AM
 
Well I sorted it out. Big thanks to Will Severance for a post he made years ago about setting a container name at runtime. It provided the basic breadcrumbs I needed to solve this one.

So here is the working code (in case someone else needs to do something similar someday)

call from within my existing method...

//hide all other modules on the page based on the mode and hide settings (only for normal users)
if (!UserInfo.IsSuperUser)
{
if (Hide == true)
{
// find all the other modules on the page so we can hide them
ModuleController moduleController = new ModuleController();
Dictionary modules = moduleController.GetTabModules(TabId);
foreach (ModuleInfo mi in modules.Values)
{
// if the module is not this module then hide it
if (mi.ModuleID != ModuleId)
{
HideContainer(mi.ModuleID).Visible = false;
}
}
}

This is the working bit that finds the correct container...

private Control HideContainer(int HiddenModuleId)
{
StringBuilder modulehandle = new StringBuilder();
modulehandle.Append("ctr");
modulehandle.Append(HiddenModuleId.ToString());

var ctl = DotNetNuke.Common.Globals.FindControlRecursive(ContainerControl, modulehandle.ToString());

if (ctl != null)
{
return ctl;
}
else
{
return null;
}
}



Steven Webster
Manager, Community Platform
F5 Networks, DevCentral
 
New Post
12/3/2011 4:27 PM
 
Posted an article with a video walk-through and downloadable module and source code about this for anyone who's interested here


Steven Webster
Manager, Community Platform
F5 Networks, DevCentral
 
New Post
12/14/2011 9:31 AM
 

Steven

Sorry for stupid question, but why you can not use just:

Me.Visible = false

?

Sergey


 
New Post
12/14/2011 11:36 AM
 
Not a stupid question at all...I thought it would be that simple myself...but that only works within the context of THIS module....I was trying to get THIS module to turn off container visibility for all of the other modules that might be on the page. Effectively emulating the ctrl/myview feature but handling it programmatically.


Steven Webster
Manager, Community Platform
F5 Networks, DevCentral
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesSetting Container Visibility at Runtime?Setting Container Visibility at Runtime?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out