Class HyperlinkHelper
Provides utility methods for validating, processing, and handling hyperlinks within Telerik controls.
Inheritance
Inherited Members
Namespace: Telerik.WinControls
Assembly: Telerik.WinControls.dll
Syntax
public static class HyperlinkHelper
Remarks
Supports validation of HTTP/HTTPS URLs, FTP links, mailto addresses, UNC paths, OneNote links, and web URLs using both URI scheme validation and pattern matching approaches.
Methods
ShowMessage(String, String, String)
Displays a warning message box to the user with hyperlink-related information.
Declaration
public static void ShowMessage(string hyperlink, string message, string caption)
Parameters
System.String
hyperlink
The hyperlink that is associated with the message, which will be appended to the message text. |
System.String
message
The message text to display to the user, typically describing the issue or validation result. |
System.String
caption
The caption text for the message box title bar. |
Remarks
Shows hyperlink-related messages with a warning icon and OK button. The hyperlink parameter is appended to the message text so users can see exactly which link caused the issue.
ValidateLinkPattern(String)
Validates a hyperlink using regular expression pattern matching to support a broader range of link formats.
Declaration
public static bool ValidateLinkPattern(string hyperlink)
Parameters
System.String
hyperlink
The hyperlink string to validate against the supported patterns. |
Returns
System.Boolean
|
Remarks
This method provides more flexible validation than ValidateLinkScheme(String) by using regular expression patterns to match various hyperlink formats. It supports:
- HTTP and HTTPS URLs (with or without www prefix)
- FTP URLs
- Mailto links
- UNC paths (\server\path)
- OneNote links
- Web addresses starting with www
- Email addresses
This validation is more permissive than URI scheme validation and is useful for scenarios where you want to accept a wider variety of link formats, including those that might need preprocessing before being used as actual URLs.
Examples
// Valid patterns
bool result1 = HyperlinkHelper.ValidateLinkPattern("https://example.com"); // returns true
bool result2 = HyperlinkHelper.ValidateLinkPattern("www.example.com"); // returns true
bool result3 = HyperlinkHelper.ValidateLinkPattern("user@example.com"); // returns true
bool result4 = HyperlinkHelper.ValidateLinkPattern("\\\\server\\share"); // returns true
bool result5 = HyperlinkHelper.ValidateLinkPattern("onenote:page-link"); // returns true
// Invalid patterns
bool result6 = HyperlinkHelper.ValidateLinkPattern("just text"); // returns false
bool result7 = HyperlinkHelper.ValidateLinkPattern(""); // returns false
ValidateLinkScheme(String)
Validates a hyperlink using strict URI scheme validation to ensure it conforms to standard URI formats.
Declaration
public static bool ValidateLinkScheme(string hyperlink)
Parameters
System.String
hyperlink
The hyperlink string to validate. |
Returns
System.Boolean
|
Remarks
Performs strict validation using the .NET Uri class. Only accepts URLs with HTTP, HTTPS, or mailto schemes. More restrictive than ValidateLinkPattern and should be used when strict validation is required.