Ke asp. NET obtains data from the kindeditor editor.

Source: Internet
Author: User

I recently used ASP. NET to create a project. I thought it was a very small project. I should have no questions.
But it was really difficult for me to implement the text editor. I spent a long time searching for information on the Internet and finally chose the KindEditor text editor.
This editor is lightweight and does not require any complicated parameter configuration. You can download the file package from the official website and decompress it. There are asp,, php, and jsp application instances, used
After that, I felt pretty good, lightweight, and flexible. It could be said that it fully met my needs and I thought everything would be fine, however, this morning, when I set the value (I used to debug the results, but I didn't take
Value storage), suddenly found that the textarea value could not be obtained in the background, so I searched the internet for a day, and finally found a solution to the problem when I was exhausted and ready to give up, below is
An instruction document from the official website:

The Visualized operations of KindEditor are executed on the newly created iframe, And the textarea box in code mode is also created. Therefore, you must set the HTML data to the original textarea and editor before the final submission. the sync () function completes this action.

KindEditor automatically finds the form element to which textarea belongs by default. After finding the form, add editor to the onsubmit event. the sync () function. Therefore, you do not need to manually execute the editor when submitting data using form. the sync () function.

Wb. value gets the value of the text editor.


<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "_ Default" %>

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "">

<Html xmlns = "">
<Head runat = "server">
<Title> </title>
<Script src = "kindeditor-4.0.4/kindeditor-min.js" type = "text/javascript"> </script>
<Script src = "kindeditor-4.0.4/lang/zh_CN.js" type = "text/javascript"> </script>
Var editor;
KindEditor. ready (function (K ){
Editor = K. create ('# TextBox2 ',{
AllowFileManager: true,
AfterCreate: function (){
Var self = this;
K. ctrl (document, 13, function (){
Self. sync ();
K ('form [name = formCreateDocument] ') [0]. submit ();
K.ctrl(self.edit.doc, 13, function (){
Self. sync ();
K ('form [name = formCreateDocument] ') [0]. submit ();
$ ('# Button1'). click (function (){
Self. sync ();
PrettyPrint ();
<Form id = "form1" runat = "server">

<Asp: TextBox ID = "TextBox2" runat = "server"> </asp: TextBox>
<Asp: Button
ID = "Button1" runat = "server" Text = "Button" onclick = "button#click"/>


---------------- Background

Protected void button#click (object sender, EventArgs e)
String txt = this. TextBox2.Text;

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: 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.