Skip to main content

DxRichEdit.DocumentContent Property

Specifies an open document’s content.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

[Parameter]
public byte[] DocumentContent { get; set; }

Property Value

Type Description
Byte[]

Document content as an array of bytes.

Remarks

The DocumentFormat property specifies the format in which the DocumentContent property stores an open document’s content. Change the DocumentFormat property value before you open a file in an another format.

The Rich Text Editor updates the DocumentContent property value in the following cases:

The DocumentLoaded event fires when you use the DocumentContent property to open a document. Handle this event to change the content of an open document.

The DocumentContentChanged and DocumentContentChanging events occur every time the DocumentContent property value changes. The following code example handles the DocumentContentChanged event to save changes made to a document:

<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