Documents can be easily loaded using ASP.NET code-behind code with the Web.TextControl.LoadText and Web.TextControl.SaveText methods that accept file names, FileStreams and memory variables such as byte and string arrays.

To load a document from a physical file, the following code is required:


In order to save a document, the SaveText method is used:

TextControl1.SaveText(Server.MapPath("/output/" + sFilename),

Web.TextControl must be initialized completely in order to accept LoadText calls. Therefore, it exposes another method to load documents: Web.TextControl.LoadTextAsync. This method loads the text asynchronously when the HTML5 Web Editor is initialized and loaded completely.

In order to load a document in the Page_Load event of an ASPX Web Form, the following code is used:


Web.TextControl is updated and synchronized with the server automatically using the Web Sockets protocol. In case, you want to use other server-side (runat="server") elements such as buttons on the same form, make sure that they are embedded in an AJAX UpdatePanel and doesn't post back the complete page. A typical body would look like this:

 <form id="form1" runat="server">
   <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
   <asp:UpdatePanel ID="UpdatePanel1" runat="server">
     <asp:Button ID="Button1" runat="server" Text="Load Document" />
   <cc1:TextControl ID="TextControl1" runat="server" />

More information and tutorials can be found in the documentation.