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.