SubDocument.AddHtmlAsync(String, CancellationToken) Method
In This Article
Parses HTML code and inserts the resulting content at the end of a sub-document.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
#Declaration
C#
public ValueTask<Interval> AddHtmlAsync(
string htmlText,
CancellationToken cancellationToken = default(CancellationToken)
)
#Parameters
Name | Type | Description |
---|---|---|
html |
String | The HTML code. |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
cancellation |
Cancellation |
null | An object that propagates a cancellation notification. |
#Returns
Type | Description |
---|---|
Value |
A structure that stores an awaitable result of an asynchronous operation. The awaitable result is the inserted interval. |
#Remarks
The following code snippet inserts content of the C:\Temp\html-content.html
file at the end of a Rich Text Editor’s sub-document.
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(htmlContent);
}
await base.OnAfterRenderAsync(firstRender);
}
}
To parse HTML code and insert the corresponding content at a specific position in a sub-document, use the AddHtmlAsync(Int32, String, CancellationToken) method.
See Also