asp.net FCKeditor 使用教程

首先下載FCKEditor插件

下載網址:http://www.fckeditor.com/

這路需要下載2種文件

1.下載FCKeditor_2.6.6,fckeditor應用程序相關文件。

2.下載FCKeditor.Net_2.6.3,asp.net程序需要的dll文件。

然後創建一個web項目,將下載壓縮文件解壓。將fckeditor文件,夾拷貝到項目,刪除多餘的文件,只保留 editor文件夾,fckconfig.js,fckeditor.js,fckstyles.xml,fcktemplate.xml文件。

創建一個新的文件夾取名叫userfiles用於存儲本地上傳到服務器的文件,也是fckeditor瀏覽服務器文件的位置(文件夾位置和名稱根據個人喜好決定)。

接下來進行fckeditor項目配置

1.引入FredCK.FCKeditorV2.dll文件,該文件位於Fckeditor.net_2.6.3/bin/release/2.0/下。

2.在工具欄引用fckeditor控件,工具欄中右鍵-選擇項-.net framework組件-瀏覽-選擇剛纔引用的FredCK.FCKeditorV2.dll文件(最好引用項目下FredCK.FCKeditorV2.dll文件)。

3.將控件拖到頁面產生如下代碼:

 <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" BasePath="~/fckeditor/" Width="800px" Height="300px"></FCKeditorV2:FCKeditor>

注意:BasePath屬性不是自動生成,需要自己手動添加fckeditor應用程序文件夾路徑,該路徑可以配置在web.config中,文件夾所在項目位置不同,路徑配置也不同根據實際情況而定,

如果路徑配置不正確頁面將無法顯示編輯器。

4.配置userfiles用於存儲本地上傳到服務器的文件,即fckeditor瀏覽服務器文件夾的位置代碼如下:

  <appSettings>
    <add  key="FCKeditor:UserFilesPath" value="/fckeditor/userfiles/"/>
  </appSettings>

5.配置fckconfig.js中 FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ;用設置fckeditor編輯器的皮膚

6.配置fckconfig.js中 FCKConfig.DefaultLanguage 將默認值 en 改爲 zh-cn。

代碼如下:FCKConfig.DefaultLanguage  = 'zh-cn' ; 

7.配置fckconfig.js中var _FileBrowserLanguage 和 var _QuickUploadLanguage 將默認值 php 改爲 aspx

代碼如下:var _FileBrowserLanguage = 'aspx' ;var _QuickUploadLanguage = 'aspx' ;

8.配置fckeditor/filemanager/connectors/aspx/config.ascx文件,

private bool CheckAuthentication()
 {
  // WARNING : DO NOT simply return "true". By doing so, you are allowing
  // "anyone" to upload and list the files in your server. You must implement
  // some kind of session validation here. Even something very simple as...
  //
  //  return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
  //
  // ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
  // user logs in your system.

  // return false;

  return true;
 }

該方法用於驗證用戶是否具有上傳文件的權限,默認return false,這裏我們將false改爲true。

9.配置config.ascx文件中的SetConfig方法中: UserFilesPath = "/fckeditor/userfiles/";該方法也是設置上傳的文件夾路徑,最好與web.config中設置相同。

10.如果使用時候出現,例如具有現在危險Request.Form的值,已從客戶端偵測。

請加入頁面page標籤中加入 ValidateRuqest=false;

 代碼如下:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FCKEditor._Default" ValidateRequest="false" %>

 

這款編輯器,在處理圖片的時候是在編輯使用圖片的時候,使用的是相對路徑,例如:/imges/test.jpg

但是他在處理名稱相同的時候是重新命名

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章