menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class HyperlinkCreatingEventArgs - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class HyperlinkCreatingEventArgs

    Represents the arguments for the HyperlinkCreating event, including details about the hyperlink before it is created.

    Inheritance
    System.Object
    HyperlinkCreatingEventArgs
    Namespace: Syncfusion.Blazor.Spreadsheet
    Assembly: Syncfusion.Blazor.Spreadsheet.dll
    Syntax
    public class HyperlinkCreatingEventArgs : Object

    Constructors

    HyperlinkCreatingEventArgs()

    Declaration
    public HyperlinkCreatingEventArgs()

    Properties

    Cancel

    Gets or sets a value indicating whether the hyperlink creation should be cancelled.

    Declaration
    public bool Cancel { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean indicating whether to cancel the hyperlink creation. The default value is false. If set to true, it prevents the hyperlink from being added to the spreadsheet.

    Remarks

    When this property is set to true during the hyperlink creating event, the current hyperlink creation operation is cancelled.

    This can be useful for implementing custom validation or restricting hyperlinks in specific cells or conditions.

    Examples
    public void OnHyperlinkCreating(HyperlinkCreatingEventArgs e)
    {
        // Cancel hyperlink creation for cell A5
        if (e.CellAddress == "A5")
        {
            e.Cancel = true;
        }
    
        // Cancel hyperlinks to specific domains
        if (e.Uri != null && e.Uri.Contains("restricted-domain.com"))
        {
            e.Cancel = true;
        }
    }

    CellAddress

    Gets or sets the CellAddress for the hyperlink.

    Declaration
    public string CellAddress { get; set; }
    Property Value
    Type Description
    System.String

    A System.String representing the cell location where the hyperlink will be added. The default value is null.

    Remarks

    This property specifies the destination cell where the hyperlink will be placed in the active worksheet.

    The cell reference should be in A1 notation format (e.g., "A1", "B5", "C10").

    Examples
    public void OnHyperlinkCreating(HyperlinkCreatingEventArgs e)
    {
        // Example of setting the target cell
        e.CellAddress = "B5";
    
        // You can also set cell references programmatically
        int row = 5;
        int col = 2; // Column B
        e.CellAddress = $"{(char)(64 + col)}{row}";
    }

    DisplayText

    Gets or sets the visible display name of the hyperlink.

    Declaration
    public string DisplayText { get; set; }
    Property Value
    Type Description
    System.String

    A System.String representing the text that appears in the cell for the hyperlink. The default value is null.

    Remarks

    This property defines the user-friendly text that will be shown in the cell instead of the actual hyperlink address.

    The display name provides a meaningful description of the link destination while the actual navigation uses either a URL or cell reference specified in the DisplayText property.

    When using cell references, the display name can be different from the reference notation, offering a more user-friendly representation.

    Examples
    // Example for URL hyperlink
    public void OnHyperlinkCreating(HyperlinkCreatingEventArgs e)
    {
        // Set a descriptive display name for a URL hyperlink
        e.DisplayText = "Product Documentation";
        e.Uri = "https://docs.example.com/product";
    
        // Example of reading the display name
        string linkDisplay = e.DisplayText;
        Console.WriteLine($"Link will be shown as: {linkDisplay}");
    }
    
    // Example for cell reference hyperlink
    public void CreateCellReferenceLink(HyperlinkCreatingEventArgs e)
    {
        // Set a display name for a cell reference
        e.DisplayText = "Go to Summary Data";
        e.Uri = "Sheet2!A1"; // Cell reference format
    }

    Uri

    Gets or sets the hyperlink address for navigation.

    Declaration
    public string Uri { get; set; }
    Property Value
    Type Description
    System.String

    A System.String representing either a web URL or sheet cell reference in the format "SheetName!CellReference". The default value is null.

    Remarks

    This property supports both external web URLs (beginning with "http://" or "https://") and internal sheet references.

    For internal navigation, use the format "SheetName!CellReference" (e.g., "Sheet1!A10").

    Examples
    public void OnHyperlinkCreating(HyperlinkCreatingEventArgs e)
    {
        // Example of setting a web URL address
        e.Uri = "https://www.example.com";
    
        // Example of setting a sheet cell reference
        e.Uri = "Sheet1!A10";
    
        // You can conditionally set different types based on business logic
        if (IsExternalLink(e.DisplayText))
        {
            e.Uri = "https://www.example.com/search?q=" + e.DisplayText;
        }
    }
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved