Skip to main content
Version: 1.28 (Current)

Update HTML Module

Audience: Low-code Engineers

Skill Prerequisites: Actions, Tokens

Replaces the content of a DNN HTML module. You can replace the whole content, or use a regular expression to replace only part of it.

The content is saved through the HTML module's own versioning, so it appears in the module's version history.

note

This action is part of the Portal Management add-on. The add-on is installed and licensed separately (feature package PORTAL). If the feature package isn't licensed, the action fails with a not-licensed error.

Typical Use Cases​

  • Let administrators change a banner or announcement from a form, without editing the page
  • Publish generated content, for example a report or a list of upcoming events, to an HTML module on a schedule
  • Fill the HTML module of a page you just created with Create Page and Add Module

Don't use it to​

  • Save text that end users type without cleaning it first. The HTML is displayed as-is on the page. See Considerations.
  • Change a module's title, settings or position. Use Update Module instead.
  • Change modules that aren't DNN HTML modules.
Action NameDescription
Load HTML ModuleReads the content of an HTML module.
Sanitize HtmlRemoves unsafe markup from HTML before you save it.
Update ModuleChanges a module's properties.
Add ModuleAdds a new module to a page.
Import Module ContentOverwrites a module with exported XML.
Create PageCreates a new page.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
PageThe page that contains the module. Pick a page from the list, or enter a Tab Id, a tab path (for example //RootPage//SubPage), or a page name. When you use a name, the first page with that name is used. Leave it empty to use the current page.Yesempty stringNo
Module IdentifierThe module to update. Enter a Module Id or a module title (not case-sensitive). The module must be on the page from Page. If more than one module has the title, the first one is used.Yesempty stringYes
Regular ExpressionsA regular expression that selects the part of the current content to replace. Every match is replaced with Content. Leave it empty to replace the whole content.Yesempty stringNo
ContentThe new HTML. With a regular expression, it's the replacement text, so $1 refers to the first group of the match.Yesempty stringNo

Output Parameters Reference​

This action doesn't have output parameters.

Considerations​

  • The HTML isn't sanitized. Scripts and other markup in Content are saved and shown to everyone who views the page. If any part of the content comes from users, clean it first with Sanitize Html, and limit who can run the action with a condition.
  • No permission check. The action doesn't check whether the current user can edit the module or the page. Control access with the form's permissions or the action's Condition.
  • The action fails silently. If the page or the module isn't found, nothing happens and no error is raised.
  • Page is required outside a page. In workflows and API calls there's no current page, so leaving Page empty fails with Could not get current page.
  • An empty Content clears the module when no regular expression is set.
  • Partial updates can garble content. Replacing only part of the content with a regular expression can double-encode the rest of the module's HTML, so < shows up as text on the page. Prefer loading the content with Load HTML Module, changing it, and saving the whole content back. Test on a copy first.
  • In a replacement, $ is special. With a regular expression, $ followed by a number or {name} is read as a group reference. Write $$ for a literal dollar sign.
  • Content workflows. The update is based on the module's published version. On pages that use a content approval workflow, check the result in the module's version history.

Examples​

tip

To understand how to use the below examples, please see Running Examples.

1. Replace an announcement​

This action replaces the content of the HTML module titled Announcement on the Home page. The [AnnouncementText] token was cleaned with Sanitize Html earlier in the list.

{
"Title": "Update HTML Module",
"ActionType": "UpdateHtmlModule",
"Description": "Publish the new announcement",
"Condition": "[AnnouncementText] != \"\"",
"Parameters": {
"PageId": "//Home",
"ModuleId": "Announcement",
"RegexExpr": "",
"Content": "<div class=\"announcement\">[AnnouncementText]</div>"
}
}

2. Fill a module you just created​

This action writes a welcome message to the module whose Module Id is in [NewModuleId], on the page whose Tab Id is in [NewPageId].

{
"Title": "Update HTML Module",
"ActionType": "UpdateHtmlModule",
"Description": "Add welcome text to the new page",
"Parameters": {
"PageId": "[NewPageId]",
"ModuleId": "[NewModuleId]",
"RegexExpr": "",
"Content": "<h2>Welcome, [DisplayName]</h2><p>This is your project page.</p>"
}
}

Revised 09/27/2026