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...Getting StartedGetting StartedSetting and Retriving Custom SettingsSetting and Retriving Custom Settings
Previous
 
Next
New Post
8/22/2012 1:45 PM
 
Hi.

I am developing on VS 2010/C#, DNN 6.1.4 and I used Chris Hammond's development template.

I used the example code in the Settings control to create my own custom setting.

I have created other controls in this project (3 of them). It so happens that I do not use the default View or Edit controls. In DNN I created 3 pages and each page hosts one of the 3 controls that I made. (If you add the module to a page, it will put all the controls that you have created in your project on the page. I just deleted the extra controls from each page, but I left the view control on the page with my main control in order to access the settings page.)

Question 1)
How can I/do I retrieve the setting in my controls?

Here is an example of retrieving a setting from the view control:
if(Settings.Contains("Setting1"))
txtSetting1.Text = Settings["Setting1"].ToString();


If I try to use this code elsewhere in the project, I get this:
'DotNetNuke.Modules.MyProjectName.Settings' is a 'type' but is used like a 'variable'

Question 2)
Can I expect my other controls to "see" settings on other pages where there are controls from the same project?
 
New Post
8/22/2012 2:19 PM
 
First make sure your setting has been placed in TabModulesettings table. Then you know your code is good on your settings page.
Then place code inside your pagebehind:
private string setting1
{

get
{
string setting1 = "";

if (Settings.Contains("setting1"))
{
txtSetting1.Text = Settings["setting1"].ToString();
}
return setting1;

}
}

you can also call your setting anytime you wish by:
ex.
tbsetting.text = setting1;
 
New Post
8/22/2012 2:27 PM
 
this might be helpful.

http://chriscant.phdcc.com/2008/05/dn...

You can set/acces module scope settings or page/module settings.

Also, you should be able to access txtSetting1.Text = Settings["Setting1"].ToString();


Steven Webster
Manager, Community Platform
F5 Networks, DevCentral
 
New Post
8/24/2012 1:31 PM
 
After looking further into this, I believe that I have figured it out. It seems easy to get the settings out of a control. I was trying to retrieve the setting in a class (in the project) used by a control.

Ultimately I have decided to put the settings in the web.config and to retrieve them from that.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedSetting and Retriving Custom SettingsSetting and Retriving Custom Settings


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