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

來源:互聯網
上載者:User

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 路徑不對。

相關關鍵詞:
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.