Summary of how to use the Kindeditor editor in asp.net _ Web page Editor

Source: Internet
Author: User
Download down but not use Ah, the Internet can not find a similar method, may have not encountered such a problem, after a night of research demo and colleagues together to help, finally found out how to use, summed up their own, but also hope that the future needs of people to help. Here is an example of reading and saving from a database, Other parameters please refer to the official website of Kindeditor
1. First copy the following to the path to use the editor
Copy Code code as follows:

<input type= "hidden" name= "Content1" id= "Content1" value= ' <% = DataBind%> '/>
<input type= "hidden" name= "content" runat= "server" id= "content"/>
<script type= "Text/javascript" src= "Kindeditor.js" ></script>
<script type= "Text/javascript" >
document.getElementById ("Content"). Value=document.getelementbyid ("Content1"). Value; This is because the content can not be directly as a server control to use, that is, do not need to use <%=this. Content.clientid%>, so that the data can't be read,
var editor = new Kindeditor ("editor");
Editor.hiddenname = "Content"; Here is the name of the input hidden box with the runat= "server" attribute
Editor.editorwidth = "100%";
Editor.editorheight = "280px";
Editor.show ();
function Kindsubmit () {
Editor.data ();
}
</script>

2. Save button
Copy Code code as follows:

<asp:button id= "Createadmine" runat= "Server" height= "text=" Save "width=" "onclientclick=" "Kindsubmit ()" OnClick = "Createadmine_click"/>//Client commit to save

3. Background reading
ASPX pages:
Copy Code code as follows:

<input type= "hidden" name= "content" id = "Content" value= ' <%=editorvalue%> '/>///I want to use <% = variable%> to read server side ED The value of the Itorvalue variable initializes the contents of the editor
<input type= "hidden" name= "Contents" runat= "Server" id= "contents"/>
<script type= "Text/javascript" src= "/editor/kindeditor.js" ></script>
<script type= "Text/javascript" >
document.getElementById ("<%=this.contents.clientid%>"). Value = document.getElementById ("content"). Value;
document.getElementById ("Contents"). Value = document.getElementById ("content"). Value;
var editor = new Kindeditor ("editor");
Editor.hiddenname = "Contents";
Editor.skinpath = "/editor/skins/default/";
Editor.iconpath = "/editor/icons/";
Editor.imageattachpath = "/editor/attached/";
editor.imageuploadcgi = "/editor/upload_cgi/upload.aspx";
Editor.csspath = "/editor/common.css";
Editor.editortype = "simple";
Editor.editorwidth = "500px";
Editor.editorheight = "300px";
Editor.show ();
function Kindsubmit ()
{
Editor.data ();
}
</script>

CS Code:
Copy Code code as follows:

protected string Editorvalue; Define a variable, the client reads the value of this variable to the editor
protected void Page_Load (object sender, EventArgs e)
{
if (! Page.IsPostBack)
{
Binddata ();
}
}
private void Binddata ()
{
String sql = "Select Content from about where id=1";
Database db = new database ();
SqlDataReader dr = db. Returndatareader (SQL);
Try
{
if (Dr. Read ())
{
Editorvalue = dr["Content"]. ToString (). Trim (); Give it the initial content here
}
}
catch (Exception msg)
{
Response.Write (Msg. message);
}
Finally
{
Db. Close ();
}
}

4. Saved values
Copy Code code as follows:

Name = content. Value;
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.