SoFunction
Updated on 2025-04-13

Summary of how to use KindEditor editor

I can't use it after downloading it. I can't find a similar method on the Internet. I may not have encountered such a problem. After a night of research, demo and colleagues helped me, I finally figured out how to use it. I summarized it myself and hope it will be helpful to those who need it in the future. Here I take a reading and saving from the database as an example. Please refer to the official website of kindeditor for other parameters.
1. First copy the following to the path to the editor
Copy the codeThe code is as follows:

<input type="hidden" name="content1" value='<% = databind %>'/>
<input type="hidden" name="content" runat="server" />
<script type="text/javascript" src=""></script>
<script type="text/javascript">
("content").value=("content1").value; //This sentence is because content cannot be used directly as a server control, that is, there is no need to use <%=%>, so the data cannot be read.
var editor = new KindEditor("editor");
= "content"; //Here is the name of the input hidden box with Runat="server" attribute
= "100%";
= "280px";
();
function KindSubmit() {
();
}
</script>

2.Save button
Copy the codeThe code is as follows:

<asp:Button ID="CreateAdmine" runat="server" Height="22" Text="Save" Width="42" OnClientClick="KindSubmit()" OnClick="CreateAdmine_Click" /> //You need to submit the client to save

3. Backend reading
Aspx page:
Copy the codeThe code is as follows:

<input type="hidden" name="content" id = "content" value='<%=EditorValue %>' /> // Here you need to use <% = variable %> to read the value of the server-side EditorValue variable as the editor initialization content
<input type="hidden" name="contents" runat="server" />
<script type="text/javascript" src="/editor/"></script>
<script type="text/javascript">
//("<%= %>").value = ("content").value;
("contents").value = ("content").value;
var editor = new KindEditor("editor");
= "contents";
= "/editor/skins/default/";
= "/editor/icons/";
= "/editor/attached/";
= "/editor/upload_cgi/";
= "/editor/";
= "simple";
= "500px";
= "300px";
();
function KindSubmit()
{
();
}
</script>

CS code:
Copy the codeThe code is as follows:

protected string EditorValue; //Define a variable, and the client reads the value of this variable and assigns it to the editor
protected void Page_Load(object sender, EventArgs e)
{
if (!)
{
BindData();
}
}
private void BindData()
{
string sql = "select Content from About where id=1";
DataBase db = new DataBase();
SqlDataReader dr = (sql);
try
{
if (())
{
EditorValue = dr["Content"].ToString().Trim(); // Assign it initial content here
}
}
catch (Exception msg)
{
();
}
finally
{
();
}
}

4. Saved value
Copy the codeThe code is as follows:

Name = ;