需要的資源包我放我資源里了,不要積分
https://download.csdn.net/download/wybshyy/88245895
首先把FredCK.FCKeditorV2.dll添加到引用
具體方法如下,一個(gè)是客戶端版本,一個(gè)是服務(wù)器端版本
客戶端版本:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CaseTemplate_ADD.aspx.cs" Inherits="MyProject.CaseTemplate_ADD" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>編輯</title>
<link href="/JS/layui/css/layui.css?v=1.0" rel="stylesheet" />
<link href="/layuiadmin/style/admin.css?v=1.0" rel="stylesheet" />
<script src="/JS/jquery-3.4.1.js?v=1.0"></script>
<script src="/layuiadmin/layui/layui.js?v=1.0"></script>
<script src="/layuiadmin/lib/admin.js?v=1.0"></script>
<script src="/JS/layui/layui.js?v=1.0"></script>
<script src="/kfckeditor/fckeditor.js?v=1.0"></script>
</head>
<body>
<div class="layui-fluid">
<div class="layui-card">
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form" action="">
<div class="layui-form-item">
<label class="layui-form-label">名稱</label>
<div class="layui-input-block">
<input type="text" id="names" lay-verify="names" autocomplete="off" placeholder="請輸入名稱" class="layui-input" value="<%=strNames %>" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">模板內(nèi)容</label>
<div class="layui-input-block">
<script type="text/javascript">
var fckeditor = new FCKeditor('FCKeditor1');//新建一個(gè)fckeditor實(shí)例
fckeditor.BasePath = "/kfckeditor/";//設(shè)置編輯器的位置,該位置一定要以/結(jié)尾,這個(gè)basepath是指 fckeditor文件夾下所有文件的地址,默認(rèn)值是這個(gè),但是我們一般前面還要加上工程的名字,如/prj/fckeditor/這樣
fckeditor.Create();//創(chuàng)建并且調(diào)用一個(gè)fckeditor編輯器
</script>
</div>
</div>
</form>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button class="layui-btn sim_btn">提交</button>
<input type="button" id="btnReset" class="layui-btn layui-btn-primary" value="重置" />
</div>
</div>
</div>
</div>
</div>
</div>
<input type="hidden" id="hdid" value="<%=strid %>" />
<script type="text/javascript">
//這里一定要設(shè)置全局變量,不然下面用的時(shí)候,未定義
var layer, form, laypage, laydate, upload, layedit, indexs01, indexs02, indexs03;
$(function () {
layui.use(['index', 'layer', 'form', 'laypage', 'laydate', 'upload', 'jquery', 'layedit'], function () {
layer = layui.layer;
form = layui.form;
laypage = layui.laypage;
laydate = layui.laydate;
upload = layui.upload;
layedit = layui.layedit;//注冊layedit
var $ = layui.jquery;
});
//提交表單
$("body").on("click", ".sim_btn", function () {
saveData();
});
});
function saveData() {
var errorMsg = "";
var id = $("#hdid").val();
var names = $("#names").val();//
var contents = $("#xEditingArea").html();//
//var oEditor = FCKeditorAPI.GetInstance('FCKeditor1');
var oEditor = FCKeditorAPI.GetInstance("FCKeditor1");
alert(oEditor.GetXHTML(true));//獲取FCK編輯器里的值
alert(FCKeditor1);
alert(FCKeditor1___Config);
return false;
if (names == "") {
errorMsg = "請輸入名稱";
}
//if (names == "") {
// errorMsg = "請輸入姓名";FCKeditor1 FCKeditor1___Config
//}
if (errorMsg != "") {
layer.msg(errorMsg, { icon: 7 });
return false;
}
loadIndex = layer.load(0);
var url = "/CaseTemplate_ADD.aspx";
$.ajax({
type: "POST",
url: url,
dataType: "JSON",
data: { 'action': 'SaveData', 'id': id, 'typeID': typeID, 'names': names, 'links': links, 'isShow': isShow, 'orderNum': orderNum },
success: function (result) {
if (result.State) {
layer.close(loadIndex);
layer.msg("操作成功", { time: 1000 });
setTimeout(closeRefresh, 1000);//關(guān)閉當(dāng)前iframe,刷新指定iframe
}
else {
layer.msg(result.ErrorMsg, { time: 3000 });
}
}, complete: function (result) {
layer.close(loadIndex);
}
});
}
</script>
</body>
</html>
服務(wù)器端
先在配置文件里配置好,再把資源包放項(xiàng)目里
<appSettings>
? ? <add key="FCKeditor:BasePath" value="~/kfckeditor/"/>
? ? <add key="FCKeditor:UserFilesPath" value="~/Files/"/>
</appSettings>
代碼:文章來源:http://www.zghlxwxcb.cn/news/detail-675730.html
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test02.aspx.cs" Inherits="MyProject.Test02" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1">
<div>0000
<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" Height="480px">
</FCKeditorV2:FCKeditor>
</div>
</form>
</body>
</html>
取值后臺用FCKeditor1.value就可以了,提交按鈕必須要加runat="server"?文章來源地址http://www.zghlxwxcb.cn/news/detail-675730.html
到了這里,關(guān)于fckeditor編輯器的兩種使用方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!