Home » DotNetNuke - Module Development » DotNetNuke Modules – Adding Actions

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);
IDThe 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.
TitleThis 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.

CmdNameThe 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.
CmdArgThis 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.
IconThe URL to the icon to display with the Action menu option, or link.
UrlIf 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.
UseActionEventCauses 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.
SecureWhat 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,

VisibleExtra control over visibility. True or false. Most of the time you will make this true.
NewWindowWill 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

Related Post

  • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it […]
  • DotNetNuke Modules – Internationalization (part 2)DotNetNuke Modules – Internationalization (part 2) Last Thursday, we looked at how you could change the text of the modules in DotNetNuke.  Today, we want to show you how to add that same capability to your own modules.When you […]
  • DotNetNuke Modules – Retrieving SettingsDotNetNuke Modules – Retrieving Settings On Monday we discussed how to save setting information for our modules.  Today we want to pick back up where we left off and deal with retrieving that information, both in the […]
  • DotNetNuke Modules – Labels w/ no HelpDotNetNuke Modules – Labels w/ no Help While the bulk of the labels you use on a module will be DotNetNuke labels, occasionally you want to be able to put text on the screen that doesn't need context help and doesn't need to be […]
  • Changing an Existing DNN ModuleChanging an Existing DNN Module Got this question this morning from the “Ask A Question” form. “How do I make a change in an existing DotNetNuke module?  I want to add new fields to the feedback form.” I’m […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer. His commitment to quality through test driven development, vast knowledge of C#, HTML, CSS and JavaScript as well as his ability to mentor younger programmers and his passion for Agile/Scrum as defined by the Agile Manifesto and the Scrum Alliance will certainly be an asset to your organization.