DNN (Formerly DotNetNuke) Tutorial - Part 3 (Create Custom Edit Page)

Introduction

 
This is used for configuring the module behavior in different pages in the same project or in different projects. The settings may be some redirected URL or some procedure name etc.
 
Before starting with Part three, let's go through the previous two parts,
Create Custom Edit Page
 
Create a new module folder in the DesktopModules and add two usercontrols.
 
Edit
 
For Example:
 
Here, I have added two usercontrols View.ascx and Edit.ascx in EditModule folder. (You can give custom names for the usercontrols, for easy understanding I've just given View and Edit as names. )
 
Here the View.ascx page will be visible to the end-users and the Edit.ascx only for the Admin users
  • As you know all the modules should be inherited from class “PortalModuleBase”.
  • Also, we need to include some reference to the View page to call the action page “Edit.ascx”.
  1. using DotNetNuke.Entities.Modules.Actions;    
  2. using DotNetNuke.Security;   
A module action is used to define a specific function for a given module. Each module can define one or more actions which the portal will present to the user. These actions may be presented as a menu, a dropdown list, or even a group of linkbuttons.
 
Using the property ModuleActionCollection property we can add new module action to the View Page.
  1. public ModuleAction CollectionModuleActions    
  2. {    
  3.     get     
  4.     {    
  5.         ModuleActionCollection Actions = newModuleActionCollection();    
  6.         Actions.Add(this.GetNextActionID(), "Edit", ModuleActionType.ContentOptions, """"this.EditUrl("EditSSO"), true, SecurityAccessLevel.Edit, truefalse);    
  7.         return Actions;    
  8.     }    
  9. }   
this.GetNextActionID()
 
It returns an integer value, the Next Action Id.
 
“Edit”
 
It will be the title of the Page.
 
ModuleActionType.ContentOptions
 
Common action types can be specified in the CommandName attribute of the ModuleAction class
 
SecurityAccessLevel
 
The SecurityAccessLevelenum is used to determine which level of access rights to assign to a specific module or module action.
 
In the Edit.ascx page you can apply the custom configuration and settings values for the module.
 
There are two different tables for the modules TabModuleSettings and ModuleSettings.
 
Before working with a custom edit page you should learn the difference between these two.
 
ModuleSettings:
 
This Table will handle the settings that are common for the module, I mean these setting will be the same if the module is used in different tabs.
 
Tabmodulesettings:
 
As the table name describes this table is dealing with the configurations which depend on each tab. Maybe the same modules will be used in different tabs, and some of the configurations will be different. Those kinds of details will be saved in the TabModuleSettings table.
 
Configuration Changes
 
Step 1:
 Create a New module from Host Settings. Those who are not yet created the module in DNN please click here.
 
Step 2: Go to Module definition Panel in the Edit Module page and click on Add Module Control Button
 
module
 
add
 
Step 3: Here's the configuration, click on the Update button.
 
update
 
Now the Module Definition Tab will be shown 2 entries in the Module Controls Grid.
 
grid
 
Step 4:
 
Add module to the new page or to the existing page (You can refer to the same doc mentioned above for adding a new page.)
 
Step 5: Go to the page and add the module and click on the Edit This Page Button from the Top.
 
edit
 
Now you will get 3 options on the top of the module, click on the pencil image that will return the Edit page for change the configurations.
 
configurations
 
To update the custom settings we can use ModuleController.UpdateTabModuleSettingFunction. Rest of the thing you just find out and create a custom module.
 
If you have any queries please write them in the comment box.
 
Reference
Read more articles on DNN: