天天看點

CKEditor與ckfinder的配置與整合(For .net)

CKEditor與ckfinder的配置與整合(For .net)

官方網站:

CKEditor與ckfinder的配置與整合(For .net)

ckeditor:http://ckeditor.com/

CKEditor與ckfinder的配置與整合(For .net)

ckfinder:http://ckfinder.com/

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

1、CKEditor 不具備上傳功能,需要內建 CKFinder 才能實作上傳功能。      下載下傳 ckeditor 并解壓到 ckeditor(在根目錄下);      下載下傳 ckfinder 并解壓到 ckfinder (在根目錄下);       兩者處于同級目錄下;         把ckfinder目錄裡的bin下的CKFinder.dll拷貝到網站目錄bin下,引用就行了。

2、在 aspx 頁面或者 master 模闆頁 <head> 标簽中載入 ckeditor.js: <scripttype="text/javascript"src="ckeditor/ckeditor.js"></script>

   在<body>标簽中使用ckeditor: <asp:TextBox ID="Content" runat="server" TextMode="MultiLine" Height="250px" Width="500px"></asp:TextBox> 與其他 .net 控件使用方法相同,設定 Text='<%# Bind("info") %>' 可以友善與資料源進行互動。

下面這段必須放在上面代碼的後面,否則初始化編輯器時會錯誤: < script type ="text/javascript">

// CKEDITOR.replace('<%=Content.ClientID%>', {}); vareditor = CKEDITOR.replace('<%=Content.ClientID%>');

CKFinder.SetupCKEditor(editor, '/ckfinder/');  //結合上傳控件 </script>

3. ckeditor裡面的config.js 配置

CKEDITOR.editorConfig = function( config ) {      config.language = 'zh-cn';//中文      config.uiColor = '#BFEE62';//編輯器顔色      config.font_names = '宋體;楷體_GB2312;新宋體;黑體;隸書;幼圓;微軟雅黑;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana';

    config.toolbar_Full =     [         ['Source','-','Preview','-','Templates'],         ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],         ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],         ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],         '/',         ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],         ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],         ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],         ['Link','Unlink','Anchor'],           ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],         '/',         ['Styles','Format','Font','FontSize'],         ['TextColor','BGColor'],         ['Maximize', 'ShowBlocks','-','About']     ];

    config.toolbar_Basic =     [         ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-','About']     ]; config.width =771;//寬度

config.height = 250;//高度   };

配置完成後基本可以了,但是運作點選圖檔管理裡面的浏覽伺服器按鈕… 出現以下提示:

CKEditor與ckfinder的配置與整合(For .net)

解決方法: ckfinder 裡面的config.ascx的配置:

public override boolCheckAuthentication() {    return true;//(增加這句,如果你需要設定打開ckfinder通路權限可以在這裡設定哦,我這裡就不考慮權限了直接打開。)         // ... where Session[ "IsAuthorized" ] is set to "true" as soon as the         // user logs on your system.

        //return false;//(注釋這句,預設這句未被注釋)          }

CKEditor與ckfinder的配置與整合(For .net)

為了去掉這個水印也簡單 分析:

CKEditor與ckfinder的配置與整合(For .net)

解決方法: 原始加密js代碼:

xx=’xxxx...’

設 qo='123'  不能為空就行了,否則上傳按鈕變為不可用 哈哈 搞掂!

CKEditor與ckfinder的配置與整合(For .net)

沒有水印了,最後來個圖,上傳成功 ok

CKEditor與ckfinder的配置與整合(For .net)

轉載于:https://www.cnblogs.com/ieage/archive/2011/11/03/2234503.html

c#