Skip to main content

ASPxRichEdit.Saving Event

Allows you to implement custom saving logic.

Namespace: DevExpress.Web.ASPxRichEdit

Assembly: DevExpress.Web.ASPxRichEdit.v22.1.dll

Declaration

public event DocumentSavingEventHandler Saving

Event Data

The Saving event's data class is DocumentSavingEventArgs. The following properties provide information specific to this event:

Property Description
DocumentID Gets the document’s unique identifier.
Handled Gets or sets whether the event is handled manually, so no default processing is required.
MultiUserConflict Gets a value identifying the multi-user conflict reason.
MultiUserConflictResolve Gets or sets a value specifying how to resolve an open document’s multi-user conflict.

Remarks

Handle the Saving event to save a document in a custom manner. The event fires when you call the Save() method or when a user clicks the Save or SaveAs ribbon command.

A custom implementation is required when ASPxRichEdit does not have enough information to complete the document save operation automatically. Such situations occur when the control is about to save a new document or a document opened from a custom document storage by the Open(String, DocumentFormat, Func<Stream>) or Open(String, DocumentFormat, Func<Byte[]>) method.

The event argument’s e.DocumentID property identifies the document to be saved. Implement custom logic and set the e.Handled property to true to disable the built-in save routine. If it is disabled but the handler includes no custom save procedure implementation, the save operation throws an exception.

Save a Document to a Byte Array

using DevExpress.Web.Office;

protected void ASPxRichEdit1_Saving(object source, DocumentSavingEventArgs e) {
    byte[] documentContentAsByteArray = ASPxRichEdit1.SaveCopy(DocumentFormat.Rtf);
    // Implement your custom logic to save a document to a custom storage
    e.Handled = true;
}

Save a Document to a Stream

using DevExpress.Web.Office;

protected void ASPxRichEdit1_Saving(object source, DocumentSavingEventArgs e) {
    using (MemoryStream documentContentAsStream = new MemoryStream()) {
        ASPxRichEdit1.SaveCopy(documentContentAsStream, DocumentFormat.Rtf);
        // Your custom logic to save a document to a custom storage
    }       
    e.Handled = true;
}

You can declare the Saving event handler as a globally available static method to be able to use it with the autosave feature.

See Also