SPUtility.AutoHyperlinking Method

Converts URLs and email addresses in a plain text string into hyperlinks in an HTML-encoded string.

Namespace:  Microsoft.SharePoint.Utilities
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public Shared Function AutoHyperlinking ( _
    value As String _
) As String
'Usage
Dim value As String
Dim returnValue As String

returnValue = SPUtility.AutoHyperlinking(value)
public static string AutoHyperlinking(
    string value
)

Parameters

Return Value

Type: System.String
An HTML string containing an encoded version of the original string with embedded URLs and email addresses converted into hyperlinks.

Remarks

This method searches for any URLs or email addresses in the specified string and converts them into HTML A tags.

Examples

The following example is part of a console application that converts a URL and an email address into two hyperlinks.

string plainText = "For more information on "Sample Product", see https://www.microsoft.com or e-mail someone@microsoft.com.";
string htmlText = SPUtility.AutoHyperlinking(plainText);
Console.WriteLine(htmlText);

The example produces the following output:

For more information on &quot;Sample Product&quot;, see <a href="https://www.microsoft.com">https://www.microsoft.com</a> or e-mail <a href="mailto:someone@microsoft.com">someone@microsoft.com</a>.

See Also

Reference

SPUtility Class

SPUtility Members

Microsoft.SharePoint.Utilities Namespace