If you are a customized DNN developer, in common you way utilize the built-in module settings with inheriting the base class "ModuleSettingsBase". You should be careful with your use of the two types of settings that can be associated with an instance of a custom module - there are Module settings and Tab-Module settings. As Chris Cant shared in his post [DNN module and tab-module settings]:
The Module settings are associated with all instances of a module on several pages, while the Tab-Modulesettings are only associated with one instance (on a single page).
When you copy a module instance to a new page with Add Existing Module, only the Module settings are available on the new page. So, if you want settings to be available after a module has been copied, then use Module settings, not Tab-Module settings.
When a module's content is exported using Export Content, the module controller is called with the ModuleId only (i.e. without the TabModuleId). This only provides easy access to the Module settings.
So when you are developing your DNN modules, the specific requirements will decide what you want to utilize. Now I would like to share some sample coding about how to migration DNN module settings based these discussed above. Yep, at first your module controller must implement IPortable interface of DNN framework and then you must implement two methods "public string ExportModule(int moduleID)" and "public void ImportModule(int moduleID, string content, string version, int userId)":
The coding to export your module settings:
var objModuleController = new ModuleController();
var objSettings = objModuleController.GetModuleSettings(moduleID);
var settingsElem = new XElement("settings");
foreach (var key in objSettings.Keys)
{
var item = new XElement("setting");
var keyElem = new XElement("key", key);
var valueElem = new XElement("value", objSettings[key].ToString());
item.Add(keyElem);
item.Add(valueElem);
settingsElem.Add(item);
}
XElement root = new XElement("Root");
root.Add(settingsElem);
return root.ToString();
The coding to import external module settings:
XElement xSettings = xRoot.Element("settings");
var objModuleController = new ModuleController();
foreach (var xField in xSettings.Elements())
{
objModuleController.UpdateModuleSetting(moduleID, xField.Element("key").Value, xField.Element("value").Value);
}
If you have better solution or any question please feel free to share with us in the comments.