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...How does one add How does one add 'user\admin settable' properties to a module?
Previous
 
Next
New Post
4/1/2008 1:47 PM
 

Afternoon Folks,

Ok, I'm working on creating a new batch of modules, which are going to be hitting an existing backend.

I've actually gotten the first batch of controls working, enough to make my boss happy for now, but eventually, we're going to have to make these a bit more complicated...

Specifically, I'm going to need the option of either having the users\admin set certain values in the module settings when they add a module to a specific 'page' of the site, otherwise, it will attempt to set the default values based off of the query string at run time. 

So, how does one go about adding user defineable values to the 'settings' section of the module (which I've never actually created as of yet) and then how does one retrieve those values at run time?

Thanks,
Brian

 
New Post
4/2/2008 5:41 PM
 

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

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...How does one add How does one add 'user\admin settable' properties to a module?


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