Intersoft Support Center

Save and Load Content to HTML File

WebTextEditor provides a method to save the content to a document during server-side event.

In this topic, you will learn how to save a document.

To save and load document to WebTextEditor

  1. To save content to file, use the provided SaveContentToFile server side method. There are 3 parameter for this method "fileName", "sectionName" and "docType". "sectionName" parameter is used to save the content from a specific editor section, where as "docType" is used to save the editor's content including html declaration (by default there is no html declaration). There are 2 options for "DocType", HTMLDocType and XHTMLDocType.

  2. Place the following code in button click event to save content to HTML file.

    C# Copy ImageCopy Code
    protected void Button1_Click(object sender, EventArgs e)
    {
       WebTextEditor1.SaveContentToFile(Server.MapPath("./SampleHtml/SavedFile.html"), WebTextEditorHtmlDocType.XHTMLDocType, "Title Name", true);
    }                       
                            

  3. To load content from file, please use LoadContentFromFile server side method. There are several parameters provided in this method such as "fileName", "sectionName" , "isCompleteHTML". "sectionName" parameter is used to load from file to specific section of editor (multiple section), "isCompleteHTML" parameter should be set to true if loaded file is a full/complete html file.

  4. Place the following code in button click event to load content from HTML file.
    C# Copy ImageCopy Code
    protected void Button1_Click(object sender, EventArgs e)
    {
       WebTextEditor1.LoadContentFromFile(Server.MapPath("./SampleHtml/Product Overview.html"), true);
    }
    

  5. Run the project.
Previous Next