Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxRichEdit.DocumentContentChanged Event

Allows you to save document content changes.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
[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:

Razor
<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