下载最新版本的KindEditor,然后采用JS赋值
insertHtml(val)
appendHtml(val)
html(val)
三个方法全部不行。上代码!
<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeBehind="KindEditorStudy.aspx.cs" Inherits="KindEditorStudy.header" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../../KindEditor/kindeditor.js" type="text/javascript"></script>
<script src="../../KindEditor/kindeditor-min.js" type="text/javascript"></script>
<link href="../../KindEditor/themes/default/default.css" rel="stylesheet" type="text/css" />
<link href="../../KindEditor/plugins/code/prettify.css" rel="stylesheet" type="text/css" />
<script src="../../KindEditor/lang/zh_CN.js" type="text/javascript"></script>
<script src="../../KindEditor/plugins/code/prettify.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.js" type="text/javascript"></script>
<script src="../KindEditorStudy.js" type="text/javascript"></script>
</head>
<body>
<div>
<table >
<tr>
<td >
<textarea id="editor_id" cols="100" rows="8" style="width:700px;height:200px;visibility:hidden;" runat="server"></textarea>
</td>
</tr>
<tr>
<td >
<input type="button" value="提交" id="btn_Save" onclick ="return SaveInsuranceClause()"/>
</td>
<td>
</td>
</tr>
</table>
</div>
</body>
</html>
KindEditorStudy.js,也非常单纯
$(document).ready(function ()
{
KindEditor.ready(function (K)
{
var editor1 = K.create('#editor_id', {
cssPath: '../plugins/code/prettify.css',
uploadJson: '/KindEditor/upload_json.ashx',
fileManagerJson: '/KindEditor/file_manager_json.ashx',
allowFileManager: true,
afterCreate: function ()
{
var self = this;
K.ctrl(document, 13, function ()
{
self.sync();
});
K.ctrl(self.edit.doc, 13, function ()
{
self.sync();
});
$("#btn_Save").click(function ()
{
self.sync();
})
},
afterChange: function (e) { this.sync() }
});
});
LoadData();
})
function SaveData()
{
//ajax验证数据
$.ajax({ global: true, url: "Request.cs", data: { ActionName: "SaveData", Content: $("#editor_id").val()},
success: function (data)
{
if (data == "true")
{
alert("保存数据成功!");
}
else
{
alert("对不起,请您按照提示输入!");
}
},
error: function (e)
{
alert(e);
},
dataType: "json",
type: "POST",
async: true
});
}
function LoadData()
{
$.ajax({ global: true, url: "Request.cs", data: { ActionName: "GetDataList" },
success: function (data)
{
if (data.error == true)
{
alert(data.message);
}
if (data == null)
{
alert('没有查询数据!');
}
else
{
ShowData(data);
}
},
error: function (e)
{
alert(e);
},
dataType: "json",
type: "POST",
async: true
});
}
function ShowData(data)
{
if (data.length > 0)
{
//这里方法没有一个可以赋值
// $("#editor_id").appendHtml(data.Content);
//KindEditor.insertHtml('<strong>HTML</strong> code');
KindEditor.html(editor_id, '1111');
//editor.html('<strong>HTML</strong> code');
//KindEditor.exec('inserthtml',data.Content);
//KindEditor.appendHtml(data.Content);
// $("#editor_id").val(data.Content);--->这个方法到是可以赋值,页面不显示
// $("#editor_id").html(data.Content);
}
}
//