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

Introduction

This is used for configuring the module behavior on 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 a Custom Edit Page

Create a new module folder in the DesktopModules and add two user controls.

DesktopModules

For Example

Here, I have added two user controls View.ascx and Edit.ascx in the EditModule folder. (You can give custom names for the user controls, for easy understanding I've just given View and Edit as names. )

Here is the View.ascx page will be visible to the end-users and the Edit.ascx only be for the Admin users

  • As you know all the modules should be inherited from the class “PortalModuleBase”.
  • Also, we need to include some reference to the View page to call the action page “Edit.ascx”.
using DotNetNuke.Entities.Modules.Actions;
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 that the portal will present to the user. These actions may be presented as a menu, a dropdown list, or even a group of link buttons.

Using the property ModuleActionCollection property we can add new module action to the View Page.

public ModuleAction CollectionModuleActions
{
    get
    {
        ModuleActionCollection Actions = new ModuleActionCollection();
        Actions.Add(this.GetNextActionID(), "Edit", ModuleActionType.ContentOptions, "", "", this.EditUrl("EditSSO"), true, SecurityAccessLevel.Edit, true, false);
        return Actions;
    }
}

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.

  1. TabModuleSettings
  2. 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 settings will be the same if the module is used in different tabs.

Tabmodulesettings

As the table name describes this table deals with the configurations that 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 have not yet created the module in DNN please click here.

Step 2. Go to the Module definition Panel on the Edit Module page and click on the Add Module Control Button.

Edit Module page

Add module

Step 3. Here's the configuration, click on the Update button.

Update button

Now the Module Definition Tab will be shown 2 entries in the Module Controls Grid.

Module Controls Grid

Step 4. Add the 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 add the module and click on the Edit This Page Button from the Top.

Page Button

Now you will get 3 options on the top of the module, click on the pencil image that will return to the Edit page to change the configurations.

Configuration

To update the custom settings we can use.

ModuleController.UpdateTabModuleSettingFunction. The 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