ASPxRichEdit.Open(String, DocumentFormat, Func<Byte[]>) Method

Opens a document specified by an array of bytes.

Namespace: DevExpress.Web.ASPxRichEdit

Assembly: DevExpress.Web.ASPxRichEdit.v19.2.dll

Declaration

public void Open(
    string documentId,
    DocumentFormat format,
    Func<byte[]> contentAccessorByBytes
)
Public Sub Open(
    documentId As String,
    format As DocumentFormat,
    contentAccessorByBytes As Func(Of Byte())
)

Parameters

Name Type Description
documentId String

A string value that uniquely identifies the document to open (the document's DocumentId).

format DocumentFormat

A DocumentFormat object specifying the document format.

contentAccessorByBytes Func<Byte[]>

A method delegate to obtain a byte array from which to open the document.

Remarks

This method tries to find the specified document in a list of already opened documents maintained by the DocumentManager. If the document is found, its instance is opened in RichEdit. If the specified document has not been found in the opened documents, a delegate method specified by the contentAccessorByBytes parameter is called. It allows you to manually obtain a byte array from which to open a document (for instance, to load a document from a database).


C#
private void CustomDocumentOpening() {
    var uniqueDocumentId = GetUniqueDocumentId();

    // Open a document from a byte array 
    byte[] documentContentAsByteArray = GetByteArrayFromCustomDocumentStorage();
    using (var stream = GetStreamFromCustomDocumentStorage()) {
        ASPxRichEdit1.Open(uniqueDocumentId, DocumentFormat.Rtf, () => documentContentAsByteArray);
    }
}

private string GetUniqueDocumentId() {
    throw new NotImplementedException();
    // Obtain a previously saved DocumentId (for instance, from a database, if you have previously saved it there): 
    // return GetDocumentIdFromDatabase(); 
    // or 
    // Create a new unique identifier: 
    // return Guid.NewGuid().ToString(); 
}


private byte[] GetByteArrayFromCustomDocumentStorage() {
    throw new NotImplementedException();
    // Provide your custom logic to obtain a document (for instance, from a database) 
}
See Also