Modern web browsers support persistent data storage with an enhanced capacity up to 50MB local storage. It is possible to store data persistently or session based.
This sample shows how to use the local storage to store the current document locally and how to restore it. This can be helpful to auto save and recover a document when a connection has been disconnected.
The button Store document locally is in an AJAX UpdatePanel to save the document code-behind. Additionally, a hidden field is used to temporary store the document during the AJAX call.
On the button click event, the document is saved to a byte array and returned to the hidden field value as a Base64 based encoded string:
Back on the client, the hidden field value is saved to the local storage:
The button Restore gets the document from the local storage and loads it back into TX Text Control:
The document is now stored in the local storage and you can restore the document even after the browser has been closed or restarted.
Download the sample from GitHub and test it on your own.
Download and Fork This Sample on GitHub
We proudly host our sample code on GitHub.com/TextControl.
Please fork and contribute.
Requirements for This Sample
- Visual Studio 2012 or better
- TX Text Control .NET Server for ASP.NET (trial sufficient)