DotNetNuke Modules – Adding Actions

Monday, we took a look at the Anatomy of the View component and touched on the ModuleActions property. Today, we are going to dig into the Actions.Add() function a little deeper.

The Add() function has the following signature

public ModuleAction Add(int ID,
   string Title,
   string CmdName,
   string CmdArg,
   string Icon,
   string Url,
   bool UseActionEvent,
   SecurityAccessLevel Secure,
   bool Visible,
   bool NewWindow);
Parameter Description
ID The ID is used to generate a unique ID for the action. You can have DotNetNuke generate this for you by calling GetNextActionID() for that parameter.
Title This is the text that will display for the user. You should store this text in a RESX file and retrieve it with the following code:


For LocalizationKey, you can used the built in keys located in DotNetNuke.Entities.Modules.Actions:

public class ModuleActionType
  public const string AddContent =     "AddContent.Action";
  public const string ClearCache =     "ClearCache.Action";
  public const string ContentOptions =     "ContentOptions.Action";
  public const string DeleteModule =     "DeleteModule.Action";
  public const string EditContent =     "EditContent.Action";
  public const string ExportModule =     "ExportModule.Action";
  public const string HelpText =     "ModuleHelp.Text";
  public const string ImportModule =     "ImportModule.Action";
  public const string ModuleHelp =     "ModuleHelp.Action";
  public const string ModuleSettings =     "ModuleSettings.Action";
  public const string MoveBottom =     "MoveBottom.Action";
  public const string MoveDown =     "MoveDown.Action";
  public const string MovePane =     "MovePane.Action";
  public const string MoveRoot =     "MoveRoot.Action";
  public const string MoveTop =     "MoveTop.Action";
  public const string MoveUp =     "MoveUp.Action";
  public const string OnlineHelp =     "OnlineHelp.Action";
  public const string PrintModule =     "PrintModule.Action";
  public const string SyndicateModule =     "SyndicateModule.Action";


Or you can define your own key and put it in as a literal.

CmdName The name of the command; again, you can either define your own, or use the same built in constants listed above. In short, this is the value of the key you use in the GetString function above.
CmdArg This value is almost always blank. It is available so that you might pass in additional information to the action that will be processing the menu option.
Icon The URL to the icon to display with the Action menu option, or link.
Url If this menu will be processing the Edit link, just use EditUrl() here. If it is for some other key, use EditUrl(keyValueHere); This tells DotNetNuke what URL to create to load the specified component.
UseActionEvent Causes the portal to raise an Action Event on the server and notify any registered event listeners. Most of the time you will make this value false.
Secure What security level does the user need to be able to access this event? You can use one of the following constants from the DotNetNuke.Security namespace:

public enum SecurityAccessLevel
    ControlPanel = -3,
    SkinObject = -2,
    Anonymous = -1,
    View = 0,
    Edit = 1,
    Admin = 2,
    Host = 3,

Visible Extra control over visibility. True or false. Most of the time you will make this true.
NewWindow Will this pop up a new browser window? If so, make this value true. Otherwise, leave it false. Most of the time you will make this value false.

So in the process of explaining the action menus, we’ve introduced the concept of resource files. This is something we will take a look at in the next post of this series.


Other post in DotNetNuke - Module Development

Most Commented Post

Leave a Reply

Comment Policy:

  • You must verify your comment by responding to the automated email that is sent to your email address. Unverified comments will never show.Leave a good comment that adds to the conversation and I'll leave your link in.
  • Leave me pure spam and I'll delete it.
  • Leave a general comment and I'll remove the link but keep the comment.

Notify me of followup comments via e-mail