CKEditor与CKFinder

1、下载

CKEditor:http://ckeditor.com/download

CKFinder:http://cksource.com/ckfinder/download,下载ASP.NET版

2、放入项目中:

3、另开一个VS重新打开ckfinder/_source/CKFinder.Net.sln,编译后,将Bin/Debug/CKFinder.dll复制出来到WebApplication2下。

4、删除ckfinder文件夹下_source文件夹。

5、修改ckfinder下config.ascx文件:

public override bool CheckAuthentication()
{
        // WARNING : DO NOT simply return "true". By doing so, you are allowing
        // "anyone" to upload and list the files in your server. You must implement
        // some kind of session validation here. Even something very simple as...
        //
        //        return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
        //
        // ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
        // user logs on your system.
                //此处原来是return false;
        return true;
}

 

6、建立一个新的WebForm.aspx页面。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1"  ValidateRequest="false" %>

<!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 type="text/javascript" src="/PlugIn/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="/PlugIn/ckfinder/ckfinder.js"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <textarea id="ckeditor1" name="ckeditor1" runat="server"><p>编辑器内容</p></textarea>
        <script type="text/javascript">
            var editor = CKEDITOR.replace('ckeditor1');          // 创建编辑器
            CKFinder.setupCKEditor(editor, '/PlugIn/ckfinder/');   // 为编辑器绑定"上传控件"
        </script>
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

    </div>
    </form>
</body>
</html>

7、为防止提交html不成功,该页面设置在第一行ValidateRequest="false"。

在Web.config:

 <system.web>
        <compilation debug="true" targetFramework="4.0" />
      <httpRuntime requestValidationMode="2.0" />
    </system.web>

8、服务器端代码(测试):

  protected void Button1_Click(object sender, EventArgs e)
 {
            Label1.Text = ckeditor1.Value;
 }

9、说明:ckeditor负责格式编辑;ckfinder负责上传文件处理;上传的文件默认是存放位置在ckfinder/userfiles

转载于:https://www.cnblogs.com/hhp895/p/3475865.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值