DevExpress-Examples / mvc-richedit-save-and-load-documents-from-a-database

Open and save RichEdit documents from a database binary column.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rich Text Editor for ASP.NET MVC - How to open and save documents from a database

This code example demonstrates how to open and save RichEdit documents from a database binary column.

Implementation Details

Open a document

  • Pass a model with a binary property (rich text content to be displayed) to the RichEdit's PartialView.
  • Call the RichEditExtension.Open method to open a new document with the specified document ID and content type, and retrieve the binary content from the passed model:
@Html.DevExpress().RichEdit(settings => {
    settings.Name = "RichEditName";
    settings.CallbackRouteValues = new { Controller = "Home", Action = "RichEditPartial" };
    //...
}).Open(Model.DocumentId, Model.DocumentFormat, () => { return Model.Document; }).GetHtml()

Save a document

settings.Saving = (s, e) => {
    byte[] docBytes = RichEditExtension.SaveCopy("RichEditName", DevExpress.XtraRichEdit.DocumentFormat.Rtf);
    DXWebApplication1.Models.DataHelper.SaveDocument(docBytes);
    e.Handled = true;
};

Files to Look At

Documentation

More Examples

About

Open and save RichEdit documents from a database binary column.

License:Other


Languages

Language:Visual Basic .NET 49.4%Language:C# 39.7%Language:HTML 9.4%Language:ASP.NET 1.4%