[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Collapse]Common Concepts
  [Expand]Web.config Modifications
  [Expand]Callback Exception Handling
  [Expand]Client-Side Functionality
  [Expand]Cookies Support
  [Expand]Appearance Customization - Theming
   Icon Collection
  [Expand]Performance Optimization
  [Expand]CSS Image Sprites
   Supported Document Types
  [Expand]Accessibility Support
   Right to Left Support
   HTML Encoding
   Binary Storage Configuration
  [Expand]SharePoint Support
   Mobile Support
  [Collapse]Office Document Management
   [Expand]Document Loading
   [Collapse]Document Saving
     Standard and Custom Saving
     Auto-Saving
    Document Hibernation
   Cloud Storage Account Management
  [Expand]Web Farm and Web Garden Support
 [Expand]ASP.NET WebForms Controls
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Auto-Saving

The AutoSave feature supported by office controls helps reduce the risk of data loss by saving an open document automatically at predefined, customizable intervals. This feature is also useful if the Save button is not displayed in the ribbon UI or the ribbon is not used due to the application's UI constraints.

By default, document AutoSave is off, and you need to use a specific office control level API to enable it.

Expanded AutoSave Settings

You can control the AutoSave feature at the office control level via the following properties.

  • The AutoSaveMode property (of the AutoSaveMode type)
    Specifies whether to explicitly enable the auto-saving of documents opened by this particular office control.
    Available values are as follows:
        On - Auto-save mode is explicitly set to “on” for the control.
        Default - Specifies the default auto-save mode.

  • AutoSaveTimeout property
    Specifies a delay after which the next auto-save operation will be performed.

AutoSave is activated when a document is opened for the first time by an office control whose AutoSaveMode property is set to On. If the same document is opened by several office controls with different AutoSaveMode and AutoSaveTimeout property settings, the document only accepts the On mode for the AutoSave feature, and takes the smallest value for the auto-saving operation timeout. That is, once turned on for an open document, AutoSave cannot be turned off.

Expanded Custom Auto-saving - Using the AutoSaving Event

Custom auto-saving invokes a custom save operation on a periodic base similar to the way auto-saving triggers a standard save operation.. See the Standard and Custom Saving topic for details.

To handle custom save operations triggered by the AutoSave feature, office controls expose the AutoSaving event (DocumentManager.AutoSaving) at the DocumentManager level.

The AutoSaving event uses the same event argument (DocumentSavingEventArgs) as the Saving event of office controls. It is strongly recommended that you declare this event handler as a globally available static method and use it for both events (AutoSaving and Saving).

The following code demonstrates how to assign a handler to the AutoSaving event in the Global.asax file's Application_Start method.

The reason for having two similar but separate events is that in contrast to the Saving event, which is declared at the office control level and fired within the ASP.NET page life cycle, the AutoSaving event is declared at the server DocumentManager object level and is fired on the server by a timeout (when there is no access to instances of the ASP.NET page or an office control).

Expanded See Also

Is this topic helpful?​​​​​​​