Back to Devexpress

Content Element Filtering

aspnet-4074-components-html-editor-concepts-content-filtering-and-validation-content-element-filtering.md

latest2.9 KB
Original Source

Content Element Filtering

  • Jan 18, 2022

The ASPxHtmlEditor allows you to automatically filter content elements with the following properties:

You can specify filter rules for the following elements: tags, attributes, and style attributes.

For different element types, ASPxHtmlEditor has a property that lists filtered elements and a property that specifies the filter mode:

Filtered elementsFilter mode
HtmlEditorContentElementFiltering.TagsHtmlEditorContentElementFiltering.TagFilterMode
HtmlEditorContentElementFiltering.AttributesHtmlEditorContentElementFiltering.AttributeFilterMode
HtmlEditorContentElementFiltering.StyleAttributesHtmlEditorContentElementFiltering.StyleAttributeFilterMode

Set the filter mode properties to one of the following values:

  • WhiteList - Allow and maintain specified elements; other elements are removed.
  • BlackList - Prohibit and remove specified elements; other elements are maintained.

Example

This code sample demonstrates how to specify the following settings for content element filter:

  • All cellspacing and cellpadding attributes should be removed from the editor’s content.

  • All tags except a, p, span, img, ul, li, table, tr, and td should be removed from the editor content.

  • ASPX

aspx
<dx:ASPxHtmlEditor ID="HtmlEditor" runat="server">
     <SettingsHtmlEditing>
          <ContentElementFiltering AttributeFilterMode="BlackList" Attributes="cellspacing, cellpadding" TagFilterMode="WhiteList" Tags="a, p, span, img, ul, li, table, tr, td" />
</SettingsHtmlEditing>

Online Demo

Content Element Filtering