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

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Can't get Module Settings value in another User ControlCan't get Module Settings value in another User Control
Previous
 
Next
New Post
10/2/2012 1:32 PM
 

I've searched online and found a few examples of how to retrieve a Settings value in another user control, but I can't get it working. I've verified that the value is getting stored in the TabModuleSettings table, and I can get and set the value within the Settings.ascx.cs file by using:

// Set the value in Settings.ascx.cs UpdateSettings
        ModuleController modules = new ModuleController();
modules.UpdateTabModuleSetting(TabModuleId, "RequireRenewal", "is this even working?");

// Get the value in Settings.ascx.cs LoadSetttings
        string strRequireRenewal = (string)TabModuleSettings["RequireRenewal"];

But if I try to get that value within a nested user control in my View.ascx control, I get a null reference. What am I doing wrong? I've tried:

        ModuleController objModuleController = new ModuleController();
var tempValue = objModuleController.GetTabModuleSettings(TabModuleId);
        string strRequiredRenewal = tempValue["RequireRenewal"].ToString();

And

string strRequiredRenewal = string.Empty;
if ((string)Settings["RequireRenewal"] != "") // this evaluates to true, but fails when trying to set the value below
        strRequiredRenewal = Convert.ToString(this.Settings["RequireRenewal"]);

Is the issue because of the nested User Control? Any help is appreciated

 
New Post
10/2/2012 2:10 PM
 

I should also mention (in case it matters) both ModuleId and TabModuleId are -1 in my user control that is nested in my View.ascx.cs control. This same code within my View.ascx.cs Page_Load works fine. I must be overlooking something because I should be able to access the Settings from within a nested user control, right?


public partial class MyUserControl : PortalModuleBase, IActionable, IPortable, ISearchable
{

protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
                try
                {

ModuleController objModuleController = new ModuleController();
var tempValue = objModuleController.GetTabModuleSettings(TabModuleId);
string strRequiredRenewal = tempValue["RequireRenewal"].ToString();

  string strRequiredRenewal = string.Empty;
if ((string)Settings["RequireRenewal"] != "")
strRequiredRenewal = Convert.ToString(this.Settings["RequireRenewal"]);

}
    }
}
     }
}

 
New Post
10/2/2012 2:35 PM
 

Once again, William saves me. Thanks! It only took me two days to find this post :)

William Severance wrote:

Since the child control inherits from PortalModuleBase, I would do the following in the Page_Load handler of the parent control:

' Note: ctlManageLink is assumed to be a reference to the child control

With ctlManageLink
    .ModuleConfiguration = Me.ModuleConfiguration
    .LocalResourceFile = Me.LocalResourceFile
End With

The above allows the child control to use the parent's ModuleConfiguration (which will include ModuleId) and LocalResourceFile for any localization.

http://www.dotnetnuke.com/Resources/F...

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Can't get Module Settings value in another User ControlCan't get Module Settings value in another User Control


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