How to change value in base.settings[""] in DNN

72 views Asked by At

I am new to DNN. I have a class which contains the following line of code

string sample=base.settings["NAME"].toString();

value of the base.settings["NAME"] is already configured. Where do I change this value. That is I want the location of this value(some thing like web.config in .net). Is there any way to change this value without using coding? Thanks in Advance

1

There are 1 answers

0
Chris Hammond On

Settings are typically controlled in the ModuleSettings or TabModuleSettings.

Your Settings control would typically be a web form which allowed for the configuration of the settings. In the CodeBehind you would "save" the settings using the controllers in DNN.

var modules = new ModuleController();
modules.UpdateModuleSetting(ModuleId, "StartMessage", txtStartMessage.Text);

modules.UpdateModuleSetting(ModuleId, "DefaultRoomId", ddlDefaultRoom.SelectedValue);
modules.UpdateModuleSetting(ModuleId, "DefaultAvatarUrl", txtDefaultAvatarUrl.Text);

Accessing the settings is then as easy as referencing

var settingValue = Settings["DefaultRoomId"].ToString().

To be safe you can always "check" to see if the setting exists first

if (Settings.Contains("DefaultRoomId"))
{
    var settingValue = Settings["DefaultRoomId"].ToString().
}