Intersoft Support Center

Save and Load Content

You can save and load content to HTML/Database.

In this topic, you will learn how to save and load content.

To save and load content to HTML

  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.

To save and load content to Database

  1. Bind Editor(Editor.mdb) database to AccessDataSource control.
  2. Place the following code in button click event to save content to database.
    C# Copy ImageCopy Code
    protected void Button1_Click(object sender, EventArgs e)
    {
       AccessDataSource1.UpdateParameters["ID"].DefaultValue = "1";
       AccessDataSource1.UpdateParameters["EditorName"].DefaultValue = "Budianto";
       AccessDataSource1.UpdateParameters["ScriptInformation"].DefaultValue = TextEditor1.RootTextEditor.Content;
       AccessDataSource1.Update();
    }

  3. Place the following code in button click event to load content from database.
    C# Copy ImageCopy Code
    protected void Button1_Click(object sender, EventArgs e)
    {
       DataView data = (DataView)AccessDataSource1.Select(DataSourceSelectArguments.Empty);
       TextEditor1.RootTextEditor.Content = data.Table.Rows[0]["ScriptInformation"].ToString();
    }

  4. Run the project.
Previous Next