ASPxHtmlEditor.CorrectHtml(String, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, AllowedDocumentType, Boolean, Boolean, Boolean) Method
Validates and corrects the passed HTML code based upon the options specified.
Namespace: DevExpress.Web.ASPxHtmlEditor
Assembly: DevExpress.Web.ASPxHtmlEditor.v18.2.dll
Declaration
public static string CorrectHtml(
string html,
bool allowScripts,
bool allowIFrames,
bool allowFormElements,
bool updateBoldItalic,
bool updateDeprecatedElements,
bool allowIdAttributes,
bool allowStyleAttributes,
AllowedDocumentType allowedDocumentType,
bool allowHTML5MediaElements,
bool allowObjectAndEmbedElements,
bool allowYouTubeVideoIFrames
)
Parameters
Name | Type | Description |
---|---|---|
html | String | A string value that specifies the HTML code to process. |
allowScripts | Boolean | true if scripts are allowed within the HTML code; false if scripts are automatically removed from the HTML code. |
allowIFrames | Boolean | true if iframe elements are allowed within the HTML code; false if iframe elements are automatically removed from the HTML code. |
allowFormElements | Boolean | true if form elements are allowed within the HTML code; false if form elements are automatically removed from the HTML code. |
updateBoldItalic | Boolean | true, if the b and i elements should be replaced with the strong and em elements within the HTML code; otherwise, false. |
updateDeprecatedElements | Boolean | true, if deprecated elements should be replaced with their valid analogs within the HTML code; otherwise, false. |
allowIdAttributes | Boolean | true if ID attributes are allowed within the HTML code; false if ID attributes are automatically removed from the HTML code. |
allowStyleAttributes | Boolean | true if style attributes are allowed within the HTML code; false if style attributes are automatically removed from the HTML code. |
allowedDocumentType | AllowedDocumentType | One of the AllowedDocumentType enumeration values that specifies the allowed document type. |
allowHTML5MediaElements | Boolean | true if audio and video elements are allowed within the HTML code; false if the elements are automatically removed from the HTML code. |
allowObjectAndEmbedElements | Boolean | true if object and embed elements are allowed within the HTML code; false if the elements are automatically removed from the HTML code. |
allowYouTubeVideoIFrames | Boolean | true if iframe elements, which contain link to YouTube video, are allowed within the HTML code; false if the elements are automatically removed from the HTML code. |
Returns
Type | Description |
---|---|
String | A string value that is the resulting validated HTML code. |
Remarks
Use the CorrectHtml method to process any required HTML code to make it valid, safe and compliant with the specified document type (via the HtmlEditorHtmlEditingSettings.AllowedDocumentType property): XHTML 1.0 Transitional, HTML5, or both. The resulting HTML code is always kept safe, since the method removes all potentially harmful code - unknown tags and attributes, script elements, client-side event handlers and URLs with script content. Automatic validation also helps to keep the HTML code validity by correcting invalid tag hierarchies and changing invalid attribute values.
To learn more, see the HTML Validation topic.