Skip to content

Example of Paste from MS Word in ASP.NET MVC Rich Text Editor Control

This example demonstrates the paste cleanup feature of the Rich Text Editor control. Copy your content from MS Word or other website, and paste it within the editor to cleanup.

Properties

The Rich Text Editor allows to paste the HTML content from MS Word or other websites. The editor cleans up the pasted HTML content by considering the following items.

  • The unformatted HTML element (MS Office XML format) content to standard HTML elements, and its list paragraphs to real lists.
  • The MS Office prefixed style properties are removed and what is left is made safe.
  • The unwanted tags, CSS styles, and comments are removed from the copied content.

The following settings are available to clean up the content in the PasteCleanupSettings property:

  • Select any option in the Format Option drop down list for the pasted content.
    • Select the Prompt option to invoke a prompt dialog with paste options on pasting the content in the editor.
    • Select the Plain Text option to paste the content as plain text.
    • Select the Keep Format option to keep the same format in the copied content.
    • Select the Clean Format option to remove the style format in the copied content.
  • Fill the Denied Tags text box to ignore the tags when pasting HTML content (their text is kept). For example:
    • a[!href] – paste the content by filtering anchor tags that don’t have the ‘href’ attribute.
    • a[href, target] – paste the content by filtering anchor tags that have the ‘href’ and ‘target’ attributes.
  • Fill the Denied Attributes text box to paste the content by filtering out these attributes from the content. For example:
    • id, title – This will remove the attributes ‘id’ and ‘title’ from all tags.
  • Fill the Allowed Style Properties text box to paste the content by accepting these style properties and removing the others. For example:
    • color, font-size – This will allow only the style properties ‘color’ and ‘font-size’ in each pasted element (the editor then keeps those of them its own style rules allow).