Share via


HtmlValidationContext.ValidateHtml Method (String)

Removes unsafe or disallowed HTML markup and returns validated HTML.

Namespace:  Microsoft.SharePoint.Publishing.Fields
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

Syntax

'Declaration
Public Function ValidateHtml ( _
    inputHtml As String _
) As String
'Usage
Dim instance As HtmlValidationContext
Dim inputHtml As String
Dim returnValue As String

returnValue = instance.ValidateHtml(inputHtml)
public string ValidateHtml(
    string inputHtml
)

Parameters

Return Value

Type: System.String
The validated HTML, from which all unsafe or disallowed content is removed.

Remarks

Removes any tags, attributes, or markup from an HTML string that are unsafe or do not conform to the constraint settings that have been applied to this HtmlValidationContext object.

Examples

string reportString = "Validating the following HTML \n[" + htmlContentToValidate + "]";

HtmlValidationContext validationContext = new HtmlValidationContext();

reportString += 
"First validate with no constraints to remove unsafe content only \n[" + 
validationContext.ValidateHtml(htmlContentToValidate) + "]";

Note

This example is part of the larger ValidateHtmlCode sample in the HtmlValidationContext topic.

See Also

Reference

HtmlValidationContext Class

HtmlValidationContext Members

ValidateHtml Overload

Microsoft.SharePoint.Publishing.Fields Namespace

ValidateHtml