Saturday 21 May 2011

ModuleSettings and TabModuleSettings Difference in DotNetNuke

If you do not like to read preambula and want to know what is the difference between ModuleSettings and TabModuleSettings, then you can read it here.

Have been worked with it for a long time. Also asked a lot of DotNetNuke gurus, but they did not provide concrete answer about difference between ModuleSettings and TabModuleSettings. In generally it looks the same. For example, we have Settings.ascx. Inside we save some settings, for example Template. So our code should be like this:


ModuleController objModules = new ModuleController();

objModules.UpdateModuleSetting(ModuleId, "template", tbSettings.Text);



or you can use



ModuleController objModules = new ModuleController();

objModules.UpdateTabModuleSetting(TabModuleId, "template", tbSettings.Text);



Later, when you get template from the Settings in your PortalModuleBase with code like this:



string Template = (string)Settings["template"];



It always returns the same value, nevermind what do you use ModuleSettings or TabModuleSettings. I thought it is true until yesterday. Yesterday i had to write module for one customer who uses "Adding of existing module" to the different pages. This client was happy with module. But asked me to do something with settings. Always he puts link to existing module and needs to setup settings again.

After small research all is clear:
  1. When you use TabModuleSettings, then these settings work for the single place where is these module. If you ad copy of this module to another page, then TabModuleSettings returns null until you setup it.
  2. In case you need to use single settings for all modules linked to the existing one, then you should use ModuleSettings instead of TabModuleSettings. Then all of them will use the same settings.
As much i work with DotNetNuke as more i love it :)

4 comments:

  1. What about adding existing module but like a copy, how to make settings be the same for the new module ?

    ReplyDelete
  2. You can add existing module to the page. Just switch at the top "Add existing module", then select page you want to add module from and select module you want to add. And you will copy of the module at another page.

    ReplyDelete
  3. If i drop module in different pages, it is asking different settings but the above they mentioned, module drop in anynumber of pages it is taking same setting in all pages, that is wrong it is taking different settings for different pages.

    Then what is the different between updatemodulesettings and updatetabsettings.
    Please let me know.

    ReplyDelete
  4. sridhar

    Your question is not clear. Difference described in the article.

    ReplyDelete

Note: only a member of this blog may post a comment.