Back to Devexpress

SubDocument.AddHtmlAsync(Int32, String, CancellationToken) Method

blazor-devexpress-dot-blazor-dot-richedit-dot-subdocument-dot-addhtmlasync-x28-system-dot-int32-system-dot-string-system-dot-threading-dot-cancellationtoken-x29.md

latest2.6 KB
Original Source

SubDocument.AddHtmlAsync(Int32, String, CancellationToken) Method

Parses HTML code and inserts the resulting content at the specified position in a sub-document.

Namespace : DevExpress.Blazor.RichEdit

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

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public ValueTask<Interval> AddHtmlAsync(
    int position,
    string htmlText,
    CancellationToken cancellationToken = default(CancellationToken)
)

Parameters

NameTypeDescription
positionInt32

The target position in the sub-document.

| | htmlText | String |

The HTML code.

|

Optional Parameters

NameTypeDefaultDescription
cancellationTokenCancellationTokennull

An object that propagates a cancellation notification.

|

Returns

TypeDescription
ValueTask<Interval>

A structure that stores an awaitable result of an asynchronous operation. The awaitable result is the inserted interval.

|

Remarks

The following code snippet inserts the content of the C:\Temp\html-content.html file into a Rich Text Editor’s sub-document starting at the fifth character:

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

@code {
    DxRichEdit richEdit { get; set; }
    string htmlContent { get; set; }

    string pathHtml { get; set; } = @"C:\Temp\html-content.html";

    protected async override Task OnAfterRenderAsync(bool firstRender) {
        if (firstRender) {
            htmlContent = File.ReadAllText(pathHtml);
            await richEdit.DocumentAPI.AddHtmlAsync(5, htmlContent);
        }
        await base.OnAfterRenderAsync(firstRender);
    }
}

To parse HTML code and insert the corresponding content at the end of a sub-document, use the AddHtmlAsync(String, CancellationToken) method.

See Also

SubDocument Class

SubDocument Members

DevExpress.Blazor.RichEdit Namespace