Well, I’m still using 2.0 in VS2005 but I’ll take a stab at.
In your module add a new web user control called youmodualnameSettings.ascx or some thing like that (the name isn’t that important) in my example I’ll use BRAssociates_Template_View.ascx
Here is the ascx:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="BRAssociates_Template_Settings.ascx.vb" Inherits="BRAssociates.Modules.Template.Settings" %>
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>
<dnn:Label ID="lbConnString" runat="server" CssClass="Normal" /><asp:TextBox ID="tbConnString" runat="server" CssClass="NormalTextBox" Width="500" />
Here is the ascx.vb:
Imports DotNetNuke
Imports DotNetNuke.Common
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Collections.Generic
Imports System.Reflection
Imports System.Data.SqlClient
Imports DotNetNuke.Entities.Modules
Namespace BRAssociates.Modules.Template
Partial Class Settings
Inherits ModuleSettingsBase
Dim objModules As New DotNetNuke.Entities.Modules.ModuleController
Public Overrides Sub LoadSettings()
Try
If Not (Page.IsPostBack) Then
If CType(ModuleSettings("ConnString"), String) <> "" Then
tbConnString.Text = CType(ModuleSettings("ConnString"), String)
Else
tbConnString.Text = ""
End If
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Public Overrides Sub UpdateSettings()
Try
objModules.UpdateModuleSetting(ModuleId, "ConnString", tbConnString.Text.ToString())
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
End Class
End Namespace
Then in your view page:
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ConnString As String
If Not Settings("ConnString") = String.Empty Then
ConnString = Settings("ConnString")
Else
ConnString = "" 'your default if no setting was saved.
End If
End Sub
Now here comes the part that always gets me. For a web user control to be used in the admin settings page, in your module definitions it MUST have a key of “Settings” I typically also give it a Title of “Settings” but I don’t think that maters. You may also want to add a few lines in your Settings.ascx.resx file put: ControlTitle_Settings.Text = “My Module Name Settings” and ModuleHelp.Text = “Some help text here.” It’s just that easy… let me know if you have any other questions.
-- Nathan Rover
Edited for color/readabiliy