Skip to main content
All docs
V21.2

Bookmarks.CreateAsync(Int32, Int32, String) Method

Creates a bookmark.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public ValueTask<Bookmark> CreateAsync(
    int startPosition,
    int length,
    string name
)

Parameters

Name Type Description
startPosition Int32

The bookmark start position.

length Int32

The bookmark length.

name String

The bookmark name.

Returns

Type Description
ValueTask<Bookmark>

A structure that stores an awaitable result of an asynchronous operation. The awaitable result is a bookmark object.

Remarks

<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 cancelled. */
        try {
        @* ... *@
            // Create a bookmark
            var bookmarkChapter2 = await richEdit.DocumentAPI.Bookmarks.CreateAsync(15, 9, "chapter2Bookmark");
            // ...
            // Create a hyperlink to the bookmark
            var hlChapter2Span = await richEdit.DocumentAPI.AddTextAsync("To learn more, see the Chapter 2");
            await richEdit.DocumentAPI.Hyperlinks.CreateAsync(hlChapter2Span.Interval, "", bookmarkChapter2.Name, "Go to Chapter 2");
            @* ... *@
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}
See Also