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
-
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.
-
Place the following code in button click event to save content to HTML file.
protected void Button1_Click(object sender, EventArgs e)
{
WebTextEditor1.SaveContentToFile(Server.MapPath("./SampleHtml/SavedFile.html"), WebTextEditorHtmlDocType.XHTMLDocType, "Title Name", true);
}
|
-
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.
- Place the following code in button click event to load content from HTML file.
protected void Button1_Click(object sender, EventArgs e)
{
WebTextEditor1.LoadContentFromFile(Server.MapPath("./SampleHtml/Product Overview.html"), true);
}
|
- Run the project.