DotNetNuke Modules – Retrieving Settings

ppl-wom-018 On Monday we discussed how to save setting information for our modules.  Today we want to pick back up where we left off and deal with retrieving that information, both in the LoadSettings() method and in the view module.

The Primary Method of Retrieval
The main retrieval method is the Settings property that is available in both the view and the settings module.  This is an indexed property that takes the key we specified in the Update methods as the indexer and returns the string that we saved as the value.

Behind the scenes, this property looks in the instance-specific settings and then in the global settings for the module and retrieves the data for us.  Since the property is set up as a hash table, all return values are typed as objects.  You’ll need to cast them to strings before you actually do anything with them.

Alternate Properties
You can also use the TabModuleSettings[] property and the ModuleSettings[] property to get the specific information.  The only reason I can think that you might want to do this is if you managed to make the key the same for a global setting and a module instance setting.  But that wouldn’t be very smart, and my naming convention for the keys makes that practically impossible.

Limitations …
The last bit of information you need to know about module settings is that the value can only be up to 2000 characters long.  At the risk of sounding like Bill Gates, 2000 characters ought to be enough for anyone.

But of course it isn’t always.

… and Solutions
I’ve only had one instance where I needed to store more than 2000 characters and fortunately I was reasonably sure that 4000 characters would do the trick.  So, I just split the data between two keys and stored half in one and half in the other.

The other solution, of course, is to store this information in your own table where you have control over the size and/or can delete rows as the data shrinks.


Other post in DotNetNuke - Module Development

Related Post

Leave a Reply

Comment Policy:

  • You must verify your comment by responding to the automated email that is sent to your email address. Unverified comments will never show.Leave a good comment that adds to the conversation and I'll leave your link in.
  • Leave me pure spam and I'll delete it.
  • Leave a general comment and I'll remove the link but keep the comment.

Notify me of followup comments via e-mail