Back to Devexpress

Bookmark.Name Property

blazor-devexpress-dot-blazor-dot-richedit-dot-bookmark.md

latest2.3 KB
Original Source

Bookmark.Name Property

Specifies the bookmark name.

Namespace : DevExpress.Blazor.RichEdit

Assembly : DevExpress.Blazor.RichEdit.v25.2.dll

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public string Name { get; }

Property Value

TypeDescription
String

The bookmark name.

|

Remarks

The name identifies a bookmark. You can use the name to get (GetAsync(String, CancellationToken) or remove (RemoveAsync(String, CancellationToken)) a bookmark.

The following code snippet creates a bookmark and a hyperlink that navigates to the bookmark.

razor
<DxRichEdit @ref="@richEdit" />

@code {
    DxRichEdit richEdit { get; set; }
    @* ... *@
    /* Surround the code that contains an asynchronous operation with a try-catch block to handle
    the OperationCanceledException. This exception is thrown when an asynchronous operation is canceled. */
        try {
        @* ... *@
            // Create a bookmark
            var bookmarkTextSpan = await richEdit.DocumentAPI.AddTextAsync("Chapter 1");
            var bookmarkChapter1 = await richEdit.DocumentAPI.Bookmarks.CreateAsync(bookmarkTextSpan.Interval, "chapter1Bookmark");
            @* ... *@
            // Create a hyperlink to the bookmark
            var hlChapter1Span = await richEdit.DocumentAPI.AddTextAsync("To learn more, see the Chapter 1");
            await richEdit.DocumentAPI.Hyperlinks.CreateAsync(hlChapter1Span.Interval, "", bookmarkChapter1.Name, "Go to Chapter 1");
            @* ... *@
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}

See Also

Bookmark Class

Bookmark Members

DevExpress.Blazor.RichEdit Namespace