下載下來(lái)可是不會(huì)用啊,網(wǎng)上也找不到類似的方法,可能都沒(méi)遇到過(guò)這樣的問(wèn)題,,經(jīng)過(guò)一個(gè)晚上的研究demo及同事一起幫忙,終于研究出了如何使用,自己總結(jié)一下,也希望對(duì)以后需要的人有所幫助.這里以一個(gè)從數(shù)據(jù)庫(kù)讀取和保存為例子,其它參數(shù)請(qǐng)參考kindeditor官方網(wǎng)站
1.首先把下面拷到要用編輯器的路徑
復(fù)制代碼 代碼如下:
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; //這句是因?yàn)椴荒苤苯影裞ontent做為服務(wù)器控件才用的,也就是不需要使用%=this.Content.ClientID%>的,那樣數(shù)據(jù)讀不出來(lái),
var editor = new KindEditor("editor");
editor.hiddenName = "content"; //這里是具有Runat="server"屬性的input隱藏框名稱
editor.editorWidth = "100%";
editor.editorHeight = "280px";
editor.show();
function KindSubmit() {
editor.data();
}
/script>
2.保存按鈕
復(fù)制代碼 代碼如下:
asp:Button ID="CreateAdmine" runat="server" Height="22" Text="保 存" Width="42" OnClientClick="KindSubmit()" OnClick="CreateAdmine_Click" /> //要客戶端提交才能保存
3.后臺(tái)讀取
Aspx頁(yè):
復(fù)制代碼 代碼如下:
input type="hidden" name="content" id = "content" value='%=EditorValue %>' /> //這里要用% =變量 %> 讀取服務(wù)器端EditorValue變量的值為編輯器初始化內(nèi)容
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代碼:
復(fù)制代碼 代碼如下:
protected string EditorValue; //定義一個(gè)變量,客戶端讀取這個(gè)變量的值賦給編輯器
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(); //在這里給它賦初始內(nèi)容
}
}
catch (Exception msg)
{
Response.Write(msg.Message);
}
finally
{
db.Close();
}
}
4.保存的值
復(fù)制代碼 代碼如下:
Name = content.Value;
您可能感興趣的文章:- springmvc+kindeditor文件上傳實(shí)例詳解
- Kindeditor編輯器添加圖片上傳水印功能(php代碼)
- 常用的HTML富文本編譯器UEditor、CKEditor、TinyMCE、HTMLArea、eWebEditor、KindEditor簡(jiǎn)介
- js控件Kindeditor實(shí)現(xiàn)圖片自動(dòng)上傳功能
- Kindeditor在線文本編輯器如何過(guò)濾HTML
- 使用JavaScript為Kindeditor自定義按鈕增加Audio標(biāo)簽
- jQuery讀取和設(shè)定KindEditor值的方法
- SpringMVC KindEditor在線編輯器之文件上傳代碼實(shí)例