zoukankan      html  css  js  c++  java
  • ckeeditor和ckfinder在asp.net中的使用

     

    一、官方Download

    1CKEditor :点击CKEditor.NET标题下的“Download zip”按钮

    下载的文件:ckeditor_aspnet_3.5.3.zip

    2CKFinder :点击Asp.net标签下的“Download zip”或者“Download tar.gz”按钮(PS:两个按钮下载的内容一样,说明

    下载的文件:ckfinder_aspnet_2.0.2.1.zip

    ——CKEditor是新一代的FCKEditor,很明显的不同点是CKEditor中文件上传功能独立出来了,需要配合使用CKFinder才能实现。

     

    二、具体配置顺序

    1、在项目中添加对应的文件

    右击网站,添加引用。依次添加两个文件夹中“\bin\Debug” 中的dll文件——CKEditor.NET.dllCKFinder.dll

    2、将文件夹“ckeditor”“ckfinder”添加到网站的根目录下

    注意,下载的文件中包括很多用不到的文件,可以稍微清理一下:

    此版本对于CKEditor只需要“\_Samples”文件夹下的“ckeditor”文件夹即可,其余都可不要。

    3、修改配置文件

    1CKEditor配置:打开“ckeditor\config.js”文件,根据需要添加配置信息

    CKEDITOR.editorConfig = function(config) {

    config.skin = 'v2'; //选择皮肤,源文件在“ckeditor\skins\”
    config.resize_enabled = false;

    // 基础工具栏
    // config.toolbar = "Basic";   
    //
    全能工具栏
    // config.toolbar = "Full";   
    //
    自定义工具栏
    config.toolbar =
    [
    ['Source', '-', 'Preview'], ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
    ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
    ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote', 'ShowBlocks'], '/',
    ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
    ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink', 'Anchor'],
    ['Image', 'Flash', 'Table', 'HorizontalRule', 'SpecialChar'], '/',
    ['Styles', 'Format', 'Font', 'FontSize'], ['TextColor', 'BGColor'], ['Maximize', '-', 'About']
    ];

    }

    2)在CKEditor中集成CKFinder,注意对应文件的路径

    将下面的内容继续添加到“ckeditor\config.js”文件中

    CKEDITOR.editorConfig = function(config) {

    ……

    config.filebrowserBrowseUrl = 'ckfinder/ckfinder.html'; //不要写成"~/ckfinder/..."或者"/ckfinder/..."

    config.filebrowserImageBrowseUrl = 'ckfinder/ckfinder.html?Type=Images';

    config.filebrowserFlashBrowseUrl = 'ckfinder/ckfinder.html?Type=Flash';

    config.filebrowserUploadUrl = 'ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files';

    config.filebrowserImageUploadUrl = 'ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images';

    config.filebrowserFlashUploadUrl = 'ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash';

     

    config.filebrowserWindowWidth = '800'//“浏览服务器弹出框的size设置

    config.filebrowserWindowHeight = '500';

    }

    3CKFinder的配置:

    打开“ckfinder\”下的用户控件config.ascx,更改其BaseUrl路径:

    BaseUrl = "~/upfiles/"; //前提条件是根目录上必需存在用来存放上传文件的upfiles文件夹。

    并且更改:

    public override boolCheckAuthentication()  {
            //return false;
          
    return true; 

    }

    至此,配置工作终于完成啦。。

     

    三、在页面应用CKEditor控件

    1、在页面中注册CKEditor控件:

        <%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

    此代码写在<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>的后面。

    2、然后,在<body>中需要放置该控件的位置加入CKEditor的实例:

    <CKEditor:CKEditorControl ID="CKEditor1" runat="server"></CKEditor:CKEditorControl>

    3、程序中使用this.CKEditor1.Text获取CKEditor控件的内容

    四、运行程序即可

     

  • 相关阅读:
    【模拟】HDU 5752 Sqrt Bo
    【数学】HDU 5753 Permutation Bo
    【模拟】Codeforces 706A Beru-taxi
    【二分】Codeforces 706B Interesting drink
    【动态规划】Codeforces 706C Hard problem
    【字典树】【贪心】Codeforces 706D Vasiliy's Multiset
    【中国剩余定理】POJ 1006 & HDU 1370 Biorhythms
    计算机存储单位
    转载_Linux下查看文件和文件夹大小
    反问题_不适定_正则化
  • 原文地址:https://www.cnblogs.com/ahuang1118/p/2050113.html
Copyright © 2011-2022 走看看