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)
1、下載 ckeditor_3.0.1.zip 並解壓到 ckeditor(在根目錄下)。
2、在 aspx 頁面或者 master 模板頁 <head> 標籤中載入 ckeditor.js:
<!-- 載入 CKEditor JS 檔案 -->
<script src="../ckeditor/ckeditor.js" type="text/javascript"></script>
在<body>標籤中使用ckeditor:
<!-- 使用 ckeditor 必須定義 class="ckeditor" -->
<asp:TextBox id="txtContent" class="ckeditor" TextMode="MultiLine" Text='<%# Bind("info") %>' runat="server"></asp:TextBox>
與其他 .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 模板頁 <head> 標籤中載入 ckfinder.js:
<!-- 載入 CKFinder JS 檔案 -->
<script src="../ckfinder/ckfinder.js" type="text/javascript"></script>
在<body>標籤中使用ckfinder:
<!-- 使用 ckeditor 必須定義 class="ckeditor" -->
<asp:TextBox id="txtContent" class="ckeditor" TextMode="MultiLine" Text='<%# Bind("info") %>' runat="server"></asp:TextBox>
與其他 .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 路徑不對。