Skip to main content

DxRichEdit.DocumentContentChanged Event

Allows you to save document content changes.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

[Parameter]
public EventCallback<byte[]> DocumentContentChanged { get; set; }

Parameters

Type Description
Byte[]

A new value of the DocumentContent property.

Remarks

The Rich Text Editor updates the DocumentContent property value and raises the DocumentContentChanging and DocumentContentChanged events in the following cases:

The DocumentContentChanging event occurs before the DocumentContentChanged event. Handle the DocumentContentChanging event to notify users that the Rich Text Editor starts saving.

The following code example handles the DocumentContentChanged event to save document changes to a file:

<DxRichEdit DocumentFormat="DocumentFormat.Rtf" DocumentContent="@documentContent"
    DocumentContentChanged="OnDocumentContentChanged" />

@code {
    byte[] documentContent;

    async Task OnDocumentContentChanged(byte[] content) {
    /* 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 {
            documentContent = content;
            await File.WriteAllBytesAsync("C:\\Users\\Public\\annual-report.rtf", documentContent);
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
    }
}
See Also