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

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Creating Settings Page for Custom Module: Object reference not set to an instance of an object.Creating Settings Page for Custom Module: Object reference not set to an instance of an object.
Previous
 
Next
New Post
8/3/2010 4:51 AM
 

Hello,

I am attempting to access the settings page that I created as part of the module I am working on. When I build the project and run it, I am having the following problem:

The project builds fine, but when I attempt to access the settings page I get the following message:

Object reference not set to an instance of an object.

When I debug the code, I find that the error is raised when the DNN core code attempts to retrieve a handle of the control:

In admin\Modules\ModuleSettings.ascx.vb:

If Not [Module] Is Nothing Then

                TabModuleId = [Module].TabModuleID

 

                'get Settings Control

                objModuleControlInfo = ModuleControlController.GetModuleControlByControlKey("Settings", [Module].ModuleDefID)

 

                If objModuleControlInfo IsNot Nothing Then

 

'
' The error is raised here.
'
                    _Control = ControlUtilities.LoadControl(Of Control)(Me.Page, objModuleControlInfo.ControlSrc)

'
'
'
                    Dim SettingsControl As ISettingsControl = TryCast(_Control, ISettingsControl)

                    If SettingsControl IsNot Nothing Then

                        'Set ID

                        _Control.ID = System.IO.Path.GetFileNameWithoutExtension(objModuleControlInfo.ControlSrc).Replace("."c, "-"c)

 

                        ' add module settings

                        SettingsControl.ModuleContext.Configuration = [Module]



I referenced the settings page correctly via the manifest (dnn) file. below is my code-behind file for my settings page:

 

Imports DotNetNuke

Imports System.Web.UI

 

Namespace WesleyTheologicalSeminary.Modules.SimpleDonations

 

    ''' -----------------------------------------------------------------------------

    ''' <summary>

    ''' The Settings class manages Module Settings

    ''' </summary>

    ''' <remarks>

    ''' </remarks>

    ''' <history>

    ''' </history>

    ''' -----------------------------------------------------------------------------

    Partial Class Settings

        Inherits Entities.Modules.ModuleSettingsBase

 

#Region "Base Method Implementations"

 

        ''' -----------------------------------------------------------------------------

        ''' <summary>

        ''' LoadSettings loads the settings from the Database and displays them

        ''' </summary>

        ''' <remarks>

        ''' </remarks>

        ''' <history>

        ''' </history>

        ''' -----------------------------------------------------------------------------

        Public Overrides Sub LoadSettings()

            Try

                If (Page.IsPostBack = False) Then

                    If CType(TabModuleSettings("SimpleDonations_Instructions_Text"), String) <> "" Then

                        txtGeneralInstructions.Text = CType(TabModuleSettings("SimpleDonations_Instructions_Text"), String)

                    End If

                End If

            Catch exc As Exception           'Module failed to load

                ProcessModuleLoadException(Me, exc)

            End Try

        End Sub

 

        ''' -----------------------------------------------------------------------------

        ''' <summary>

        ''' UpdateSettings saves the modified settings to the Database

        ''' </summary>

        ''' <remarks>

        ''' </remarks>

        ''' <history>

        ''' </history>

        ''' -----------------------------------------------------------------------------

        Public Overrides Sub UpdateSettings()

            Try

                Dim objModules As New Entities.Modules.ModuleController

                objModules.UpdateTabModuleSetting(TabModuleId, "SimpleDonations_Instructions_Text", txtGeneralInstructions.Text)

                ' refresh cache

                Entities.Modules.ModuleController.SynchronizeModule(ModuleId)

            Catch exc As Exception           'Module failed to load

                ProcessModuleLoadException(Me, exc)

            End Try

        End Sub

 

#End Region

 

    End Class

 

End Namespace


 

 

And here is my Settings.ascx page/code:

<%@ Control Language="vb" AutoEventWireup="false" CodeFile="Settings.ascx.vb" Inherits="WesleyTheologicalSeminary.Modules.SimpleDonations.Settings" %>

<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>

<%@ Register TagPrefix="dnn" TagName="SectionHead" Src="~/controls/SectionHeadControl.ascx" %>

<%@ Register TagPrefix="dnn" TagName="TextEditor" Src="~/controls/TextEditor.ascx"%>

<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.UI.WebControls" Assembly="DotNetNuke" %>

<div id="divGeneralSettingsSection" class="divGeneralSettingsSection">

    <asp:Label ID="lblSettingsInstructions" runat="server" Text="Enter instructions for user here."></asp:Label>

    <hr />

    <div style="float:left;">

        <dnn:Label ID="lblGeneralInstructions" ControlName="txtGeneralInstructions" runat="server" Text="General Instructions for Donors." CssClass="SubHead" Suffix=":" />

    </div>

    <div style="float:left;">

        <dnn:texteditor ID="txtGeneralInstructions" Text="Type in the instructions for donors here." Width="600px" Height="300px" runat="server" />

    </div>

</div>


I just would like to know if I am doing anything wrong.

Thank you for your time.

Regards,
Christopher Koeber
 
New Post
8/3/2010 5:07 PM
 
Trying to do a conversion to string, on the collection of settings is going to fail, unless the setting is there as you have a "null" value by default.

-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
8/3/2010 10:52 PM
 
Mitchel Sellers wrote:
Trying to do a conversion to string, on the collection of settings is going to fail, unless the setting is there as you have a "null" value by default.

 Well, I set the breakpoint to the LoadSettings() subroutine that I have and that subroutine isn't even called. Also, I do have that code within a Try block that is never called.

This error that I am referring to happens even before my code is called.

Thank you for your time.


Regards,
Christopher Koeber
 
New Post
8/4/2010 8:12 AM
 
May I ask a question which may shed light on the core problem I am having?

Under what circumstances would a Null Reference Exception be raised by this code:

In admin/Modules/ModuleSettings.ascx.vb: (In the Page_Init function, line 325):

_Control = ControlUtilities.LoadControl(Of Control)(Me.Page, objModuleControlInfo.ControlSrc)

This is where I am getting the problem.

I have checked my code and I am not sure what is the problem.

Can anyone help? Thanks.

Regards,
Christopher Koeber
 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Creating Settings Page for Custom Module: Object reference not set to an instance of an object.Creating Settings Page for Custom Module: Object reference not set to an instance of an object.


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