DotNetNuke: ModuleController.UpdateTabModuleSetting() truncates setting names to 50 characters

This is the second blog post in my new DotNetNuke blog series and it’s about a problem I found out when saving TabModuleSettings in my custom module.

Generally, saving ModuleSettings and TabModuleSettings in DotNetNuke is very straightforward: The DotNetNuke.Entities.Modules.ModuleController offers two simple update methods:

  • UpdateModuleSetting(int ModuleId, string SettingName, string SettingValue) for updating ModuleSettings and
  • UpdateTabModuleSetting(int tabModuleId, string settingName, string settingValue) for updating TabModuleSettings.

My code to update TabModuleSettings looks as follows:

var settingName = typeof(MyType).ToString(); // Create unique setting name
var moduleController = new ModuleController();
moduleController.UpdateTabModuleSetting(module.TabModuleId, settingName, settingValue);

This code seems to works fine, but I was not able to get the the settings back from the module’s TabModuleSettings Hashtable. After some research I found out, that DotNetNuke truncates setting names to 50 characters (I used the full qualified name of my class which exceeds the 50 characters limit to create a unique setting name). As far as I understand the framework, the reason is that the columns [SettingName] in the tables [TabModuleSettings] and [ModuleSettings] are defined as [nvarchar](50).

IMHO, the DotNetNuke should throw an ArgumentException if one uses an invalid setting name. As long as this is not the case, keep this limitation in mind when creating setting names…

Leave a comment

Your email address will not be published. Required fields are marked *

*