Have you ever created a DotNetNuke module that had an ASPX page but still needed to access your module settings on said page? An example of this scenario would be if you created an ASPX page to render an XML feed, or serve up a file, etc and it needed to know some of your module's settings. This can easily be done by passing the ModuleId in the query string to the ASPX page, and then using the GetModuleSettings(int moduleId) method of the PortalSettings type. Below is an example of how one would accomplish this.
using DotNetNuke.Entities.Portals;
protected void Page_Load(object sender, EventArgs e)
{
try
{
int moduleId = System.Convert.ToInt32(Request.QueryString["mid"]);
Hashtable settings = PortalSettings.GetModuleSettings(moduleId)
string feedTitle = (string) settings["FeedTitle"];
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
So as you can see as long as you have some way to pass in the ModuleId of the module instance you wish to access the settings of, you can use the GetModuleSettings method to load them into a Hashtable.
Posted in:
DotNetNuke Tips & Tricks on Tuesday, August 19, 2008 2:25 PM by Scott Schecter