Back to Devexpress

Save and Restore Layout

aspnet-8899-components-html-editor-concepts-layout-save-and-restore-layout.md

latest1.7 KB
Original Source

Save and Restore Layout

  • Jan 19, 2022

ASPxHtmlEditor allows you to save its layout to a database, and then restore it. This information includes all settings that control the visibility and size of visual elements, their appearance settings, etc.

The HTML Editor’s ClientLayout event allows you to save the editor’s layout on any change and restore the layout on the first page load. Use the ASPxClientLayoutArgs.LayoutMode argument’s property to get whether to save or restore the editor’s layout.

The following example demonstrates how to save/restore the ASPxHtmlEditor layout to/from a data store:

csharp
protected void ASPxHtmlEditor1_ClientLayout(object sender, 
  DevExpress.Web.ASPxClientLayoutArgs e) {
    if (e.LayoutMode == DevExpress.Web.ClientLayoutMode.Saving) {
        SaveUserLayoutToDatabase(userID, "AccountTreeList", e.LayoutData);
    }
    else {
        if (System.IO.File.Exists(fileName))
            e.LayoutData = RestoreUserLayoutFromDatabase(userID, "AccountTreeList");
    }
}
vb
Protected Sub ASPxHtmlEditor1_ClientLayout(sender As Object, _
  e As DevExpress.Web.ASPxClientLayoutArgs)
   If e.LayoutMode = DevExpress.Web.ClientLayoutMode.Saving Then
      SaveUserLayoutToDatabase(userID, "AccountTreeList", e.LayoutData)
   Else
      If File.Exists(fileName) Then
         e.LayoutData = RestoreUserLayoutFromDatabase(userID, "AccountTreeList")
      End If
   End If
End Sub