当前位置:编程学习 > asp >>

CKEditor+CKFinder+asp.net配置

CKEditor+CKFinder配置学习

 下载源码:/2012/0306/20120306084548836.rar
 

富文本编辑器学习,常见富文本编辑器有:

CKeditor(FCkeditor)、UEditor(百度推出的)、NicEdit、KindEditor

在本系列博文里,着重介绍前两种文本编辑器的使用,边学边学,还望虾米们来此指教!

 

CKEditor及CKFinder下载:

CKEditor:ckeditor_aspnet_3.6.2.zip

CKFinder:ckfinder_aspnet_2.1.1.zip

 

CKEditor解压缩:

  \

 

CKFinder解压缩:

  \

 

可以看到:CKEditor中有两个解决方案:

CKEditor.NET.sln 不带有示例的解决方案;

CKEditor.NETwithSamples.sln带有示例的解决方案;

在这里我们打开带有示例的解决方案CKEditor.NETwithSamples.sln

  \

 

调试并运行之:按下F5键即可

 

如何才能够让他带有上传附件的功能呢?

在这里我们需要配置一下CKEditor的插件——CKFinder

将解压缩后的CKFinder文件夹拷贝到CKEditor目录下的

  \

 

CKEditor.NET目录下;

即示例中的CKEditor 文件夹如下图:

  \

 

这里我们需要修改一下CKEditor及CKFinder的配置文件,让他实现上传功能;
CKEditor文件夹下的config.js
  config.js
 1 /*
 2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
 3 For licensing, see LICENSE.html or http://ckeditor.com/license
 4 */
 5
 6 CKEDITOR.editorConfig = function( config )
 7 {
 8     // Define changes to default configuration here. For example:
 9     // config.language = 'fr';
10     // config.uiColor = '#AADC6E';
11     config.language = 'zh-cn'; //中文
12     config.uiColor = '#eef5fd'; //'#CCEAFE';  //编辑器颜色
13     config.font_names = '宋体;楷体_GB2312;新宋体;黑体;隶书;幼圆;微软雅黑;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana';
14
15     config.filebrowserUploadUrl = '../common/ckeditor/uploader?Type=Files'; //上传文件的保存路径
16     config.filebrowserImageUploadUrl = '~/common/ckeditor/uploader?Type=Images'; //上传图片的保存路径
17     config.filebrowserFlashUploadUrl = '~/common/ckeditor/uploader?Type=Flash'; //上传flash的保存路径
18
19     config.toolbar_Full =
20     [
21         ['Source', '-', 'Preview', '-', 'Templates'],
22         ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print', 'SpellChecker', 'Scayt'],
23         ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
24         ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
25         '/',
26         ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
27         ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv'],
28         ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
29         ['Link', 'Unlink', 'Anchor'],
30         ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'],
31         '/',
32         ['Styles', 'Format', 'Font', 'FontSize'],
33         ['TextColor', 'BGColor'],
34         ['Maximize', 'ShowBlocks', '-', 'About']
35     ];
36
37     config.toolbar_Basic =
38     [
39     ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink', '-', 'About']
40     ];
41
42
43     config.width = 'auto'; //宽度
44
45     config.height = '200'; //高度
46 };

CKFinder文件夹下的config.ascx
  config.js
  1 <%@ Control Language="C#" EnableViewState="false" AutoEventWireup="false" Inherits="CKFinder.Settings.ConfigFile" %>
  2 <%@ Import Namespace="CKFinder.Settings" %>
  3 <script runat="server">
  4
  5     /**
  6      * This function must check the user session to be sure that he/she is
  7      * authorized to upload and access files using CKFinder.
  8 */
  9     public override bool CheckAuthentication()
 10     {
 11         // WARNING : DO NOT simply return "true". By doing so, you are allowing
 12         // "anyone" to upload and list the files in your server. You must implement
 13         // some kind of session validation here. Even something very simple as...
 14         //
 15         //        return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
 16         //
 17         // ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
 18         // user logs on your system.
 19
 20         return false;
 21     }
 22
 23     /**
 24      * All configuration settings must be d

补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,