FCKeditor新版本CKEditor3.0.1在asp.net 下进行配置的方法加图片上传

原文:http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece76310478d354501c839679d9a027fa3c2148e340b005a26b4ed7c62475595d27c1043f50b4beb847029611421c19bc8825dddbfc77569d530350642d500549144ee8d52609c60c655b8f64eb1e1b66fd3b9d2a2c82558dd22716df0f69c297003cb1fe76547f4d6e85f645b07c99c&p=8b2a910a8b8c11a058eddc65425e&user=baidu

 

CKEditor 3.0.1 在 asp.net 下进行配置的方法:

官方网站:CKEditor(Fully functional, open source editor, with source code included)

下载地址:CKEditor 3.0.1(released on 16 October 2009)

CKFinder 1.4.1.1 for Asp.net

1、下载 ckeditor_3.0.1.zip 并解压到 ckeditor(在根目录下)。

2、在 aspx 页面或者 master 模板页 标签中载入 ckeditor.js:

  
  

  在标签中使用ckeditor

  
  class="ckeditor" ' runat="server">

  与其他 .net 控件使用方法相同,设置 Text='<%# Bind("info") %>' 可以方便与数据源进行交互。

3、config.js 的自定义

/*
Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or
http://ckeditor.com/license
*/

CKEDITOR.editorConfig = function(config) {

// Define changes to default configuration here. For example:
config.language = 'zh-cn'; //配置语言
// config.uiColor = '#FFF'; //背景颜色
// config.width = 400; //宽度
config.height = 400; //高度
config.skin = 'v2'; //编辑器样式

// 取消 “拖拽以改变尺寸”功能
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']
];

};

4、要精简 ckeditor 可以将 _samples、_source 文件夹删除,lang 目录下可以只保留en.js、zh.js、zh-cn.js 三个语言文件。

5、CKEditor 不具备上传功能,需要集成 CKFinder 才能实现上传功能。

CKFinder 1.4.1.1 与 CKEditor 3.0.1 进行集成的配置方法:

官方网站:CKFinder(powerful and easy to use Ajax file manager for web browsers)

下载地址:CKFinder 1.4.1.1 for Asp.net(updated 02.10.2009)

6、下载 ckfinder_aspnet_1.4.1.1.zip 并解压到 ckfinder(在根目录下)。

7、打开 " \ckfinder\config.ascx ",修改 BaseUrl 为 BaseUrl = "~/ckfinder/userfiles/";
  // 注意“~”
  // 以 userfiles 为默认路径,其目录下会自动生成images、flash等子目录。

8、在 ckeditor/config.js 中集成 ckfinder。

// 自定义 CKEditor 样式
CKEDITOR.editorConfig = function(config) {
……
}

// 在 CKEditor 中集成 CKFinder,注意 ckfinder 的路径选择要正确。
CKFinder.SetupCKEditor(null, '../ckfinder/');

9、在 aspx 页面或者 master 模板页 标签中载入 ckfinder.js:

  
  

  在标签中使用ckfinder:

  
  class="ckeditor" TextMode="MultiLine" Text='<%# Bind("info") %>' runat="server">

  与其他 .net 控件使用方法相同,设置 Text='<%# Bind("info") %>' 可以方便与数据源进行交互。

10、可以将 _samples、_source 文件夹删除,lang 目录下可以只保留en.js、zh.js、zh-cn.js 三个语言文件。

常见错误排除方法:

症状:因为安全原因,文件不可浏览。请联系系统管理员并检查CKFinder配置文件。

语句:
public override bool CheckAuthentication()
{
reture false;
}

原因:未设置用户身份验证或者用户未登录。

症状:未知错误

语句:
public override bool CheckAuthentication()
{
reture true;
}

原因:设置不进行用户身份验证,但是 BaseUrl 路径不对。

参考资料

YaSin:将CKfinder 整合进 CKEditor3.0 (新)

EastWindBroken:CKEditor + CKFinder 配置

CKSource Docs:CKEditor Integration

 

posted on 2010-03-10 13:05  冷月孤峰  阅读(310)  评论(0)    收藏  举报