Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Programmatically set a custom module settingProgrammatically set a custom module setting
Previous
 
Next
New Post
5/21/2013 9:09 AM
 
Hi All,

I wrote some code to create a new DNN web page, set all my properties and then add one of my custom modules. However, I need to set a custom property of this module.

Here's a sample of the code that adds the module. Would the last line work to set the custom modules property called "CategoryID"?

Code:

ModuleInfo moduleInfo = new ModuleInfo();
moduleInfo.PortalID = 0;
moduleInfo.TabID = tabId;
moduleInfo.ModuleOrder = 1;
moduleInfo.ModuleTitle = "View Module";
moduleInfo.PaneName = "ContentPane";
moduleInfo.ModuleDefID = 235;
moduleInfo.InheritViewPermissions = true;
moduleInfo.AllTabs = false;
moduleInfo.Alignment = "Top";
moduleInfo.DisplayPrint = false;
moduleInfo.ModuleSettings["CategoryID"] = 3;


Thanks,
Mark
 
New Post
5/27/2013 3:38 PM
 
I'm closer to getting this but still could use some help.

My code can add the module. While it does not appear to change the setting, it does appear on the page. However, when I go to settings, I see the following error:

Error: is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Modules.Admin.Modules.ModuleSettingsPage.BindData() at DotNetNuke.Modules.Admin.Modules.ModuleSettingsPage.OnLoad(EventArgs e) --- End of inner exception stack trace ---

Does anyone know what's causing this?

Thanks,
Mark
 
New Post
5/28/2013 1:54 AM
 
Mark,

Do you save the setting? This can be done by something like

new ModuleController().UpdateModuleSetting(base.ModuleId, "CategoryID", "2");

Reading it should avoid to fire an exception as above, e.g. by

private int CategoryID()
{
    get
    {
       object o = base.Settings["CategoryID"];
       if (o == null) return -1; // or whatever default value
       return (int)o;
    }
    set { // Do the things above to save the value... }
}

Best wishes
Michael

Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
5/28/2013 8:14 AM
 
Michael,

At this point I can add any module to a new page but the error occurs when I click "manage --> settings". Normally a pop-up window would appear and show the 4 tabs titled module settings, permissions, page settings and settings. It's here that I see the error. That's all that appears in the window.

Am I missing a step in adding the module to a page? The error mentions something about module settings and I wasn't sure if there's something that I'm missing while adding it to the page.

Thanks,
Mark
 
New Post
5/28/2013 8:19 AM
 
Here's the error from the event viewer in case it helps:


ModuleId: 1660

ModuleDefId: -1

FriendlyName:

ModuleControlSource: Admin/Modules/ModuleSettings.ascx

AssemblyVersion: 6.2.5

PortalID: 0

PortalName: WSFSWeb

UserID: 1

UserName: host

ActiveTabID: 579

ActiveTabName: Test1

RawURL: /dnn613x2/DisplayUserInfo/Test1/tabid/579/ctl/Module/ModuleId/1660/language/en-US/Default.aspx?popUp=true

AbsoluteURL: /DNN613x2/Default.aspx

AbsoluteURLReferrer: http://localhost/dnn613x2/en-us/displayuserinfo/test1.aspx

UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; .NET CLR 1.1.4322; MS-RTC LM 8; InfoPath.3)

DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider

ExceptionGUID: 7c6b5b20-0a40-4b33-b9cf-1e348a7114cb

InnerException: Object reference not set to an instance of an object.

FileName:

FileLineNumber: 0

FileColumnNumber: 0

Method: DotNetNuke.Modules.Admin.Modules.ModuleSettingsPage.BindData

StackTrace:

Message: DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Modules.Admin.Modules.ModuleSettingsPage.BindData() at DotNetNuke.Modules.Admin.Modules.ModuleSettingsPage.OnLoad(EventArgs e) --- End of inner exception stack trace ---

Source:

Server Name: 2OPDW054421


 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Programmatically set a custom module settingProgrammatically set a custom module setting


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out