ClassHyperlinkHelper
Provides utility methods for validating, processing, and handling hyperlinks within Telerik controls.
Definition
Namespace:Telerik.WinControls
Assembly:Telerik.WinControls.dll
Syntax:
public static class HyperlinkHelper
Inheritance: objectHyperlinkHelper
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
hyperlink
The hyperlink that is associated with the message, which will be appended to the message text.
message
The message text to display to the user, typically describing the issue or validation result.
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
hyperlink
The hyperlink string to validate against the supported patterns.
Returns
true if the hyperlink matches any of the supported patterns (URL patterns or email patterns);
otherwise, false.
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.
Example
// 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
hyperlink
The hyperlink string to validate.
Returns
true if the hyperlink is a valid absolute URI with an HTTP, HTTPS, or mailto scheme;
otherwise, false.
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.