.net實例:FCKeditor2.5使用說明(簡潔高效)

Web. Config文件,修改appSettings元素,配置如下:


<appSettings>
  <add key="FCKeditor:BasePath" value="~/FCKeditor/"/>
<!--FCKeditor基本文件目錄-->
  <add key="FCKeditor:UserFilesPath" value="/Files" />
<!--文件上傳目錄-->

</appSettings>

把.net的bin/FredCK.FCKeditorV2.dll解壓引用就行
fckconfig.js裏有很多配置保護語言版本,上傳等設置


加到網頁的步驟:

1.引用bin/FredCK.FCKeditorV2.dll
2.將頁面切換到設計模式
3.呼出工具箱,在"常規"選項卡內點擊右鍵,選擇"選擇項",瀏覽選擇bin/FredCK.FCKeditorV2.dll,點確定後就會在工具箱的"常規"中出現一個控件.
4.在頁面處於設計模式時,將此控件拖入網頁,然後設置其ID,並在網頁的第一行標籤里加[ValidateRequest="false"]
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
5.在入數據庫時將取得值Server.HtmlEncode(),在將數據用編輯器編輯或顯示於網頁上時將數據Server.HtmlDecode()
6.取得值或判斷值時用.value
 

 
 
 
 
FCKeditor在.net(asp.net)中的使用方法
 

安裝前需求:

1.FCKeditor.Net_2.5.zip

下載地址:

http://downloads.sourceforge.net/fckeditor/FCKeditor.Net_2.5.zip

2.FCKeditor_2.6.zip

下載地址:

http://sourceforge.net/project/downloading.php?group_id=75348&filename=FCKeditor_2.6.zip

一、安裝過程:

1、將FCKeditor.Net_2.5.zip解壓縮。我們需要一個DLL文件。在/bin/Release/文件夾下有兩個版本。對應.netframework的版本,我的是.netframework2.0的,就在/bin/Release/2.0/下,拷貝FredCK.FCKeditorV2.dll至你的項目的bin目錄。然後在.net的工具箱中添加此項。

2、將FCKeditor_2.6.zip解壓縮。將所得的fckeditor文件夾拷貝至項目根目錄。打開/fckeditor/fckconfig.js

找到:

var _FileBrowserLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php | py

這兩行,大致位置在271、272兩行。

將這兩行中的PHP替換爲aspx。

找到:

UserFilesPath = "/userfiles/";

這一行,大概在第50行處。將/userfiles/替換爲你的用來存放用戶上傳文件的文件夾。

保存、退出。

3、在/fckeditor/editor/filemanager/connectors/aspx/文件夾下找到config.ascx用editplus或者文本文檔打開,找到:

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;則允許所有用戶上傳文件。建議在這個函數中判斷用戶類型,然後在根據判斷結果來確定返回值。

修改好以後,保存、退出。

4、在你的項目的配置文件:web.config裏找到<appSettings/>將它替換爲:

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

把 value="/upload/" 替換爲你的用來保存用戶上傳文件的文件夾。

如果web.config裏沒有<appSettings/>這一項,就直接把上面三行代碼放到<configuration>裏面</configuration>

注意:用來保存用戶上傳文件的文件夾必須存在,如果不存在,請自己建立。

二、使用方法:

可以直接在ASP.NET設計視圖中使用此控件,就像你使用textbox一樣簡單,直接從工具箱拖到頁面上即可。獲取FCKeditor的編輯框中的值,可以用FCKeditor的value屬性獲取編輯框內的值,此數據爲html代碼。至此,整個安裝、使用過程結束!


 

 

 

發佈了1 篇原創文章 · 獲贊 2 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章