Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

Affordable ASP.NET Hosting Service
  Ads  
r2i.ntegrated
 


  Sponsors  

Meet Our Sponsors

Portal Webhosting - Hosting For Developers
Red-Gate Software
MaximumASP
SourceGear - Tools for Developers
.: CounterSoft :.
telerik
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! (Pro...  How does one add 'user\admin settable' properties to a module?
Previous Previous
 
Next Next
New Post 4/1/2008 11:47 AM
User is offline IceWing_mk1
54 posts
10th Ranked


How does one add 'user\admin settable' properties to a module? 

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 3:41 PM
User is offline Nathan Rover
39 posts
www.websitemakers.com
10th Ranked


Re: How does one add 'user\admin settable' properties to a module? 
Modified By Nathan Rover  on 4/2/2008 5:57:04 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 Previous
 
Next Next
  Forum  General DotNetN...  Extend It! (Pro...  How does one add 'user\admin settable' properties to a module?
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Intura Vision / Intura Enterprise
Point-of-Sale and business management applications targeted towards quick service, fast casual and delivery-based restaurant concepts.
www.intura.com
Dnaxp.Net
Dnaxp.Net offers a comprehensive base of information, resources, and support for DotNetNuke.
www.dnaxp.net
DNNMasters - modules, consulting, development
DNNMasters developers are involved in DNN development since DNN 1.0.9 and today we offer a broad range of DNN related products and services including custom development of modules, help with ing third party modules for specific needs, general DNN technical support and administrative services.
www.dnnmasters.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP