ASP.NET2.0 文本编辑器FCKeditor的冰冷之心 【月儿原创】
ASP.NET2.0 文本編輯器FCKeditor的冰冷之心?
作者:清清月兒
主頁:http://blog.csdn.net/21aspnet/?????????? 時間:2007.4.9
FCKeditor是目前最好的html文本編輯器,如果還不明白的話看了下圖就知道了
效果圖:
那么為什么說是FCKeditor的冰冷之心呢?這不是嘩眾取寵,主要是說它使用起來有點麻煩,下文就詳細說明如何搞定這玩意兒。
1.FCKeditor的官方網(wǎng)站是:http://www.fckeditor.net/download?
目前最新的FCKeditor 2.4.2版本。
請在此頁下載:http://sourceforge.net/project/showfiles.php?group_id=75348
如圖所示:
要下載FCKeditor2.4.2.zip和?? FCKeditor.NET版的2個zip包。
說明:
FCKeditor2.4.2.zip是其最新的Javascript文件和圖片什么的;
FCKeditor.NET.zip是ASP.NET調(diào)用的DLL在里面。
2.分別解壓后把FCKeditor2.4.2.zip里的fckeditor目錄整個復制到網(wǎng)站中。
3.解壓FCKeditor.NET.zip包后在FCKeditor.Net_2.2/bin/Debug目錄里找到FredCK.FCKeditorV2.dll。其他文件沒用,把FredCK.FCKeditorV2.dll復制到我們的網(wǎng)站,建立一個Bin目錄。
4.引用FredCK.FCKeditorV2.dll。
第一步:
第二步:
5.導入工具箱。
在“工具箱”下右鍵
點擊“選擇項”。彈出如圖窗口:
點擊瀏覽,找到dll所在目錄。
這時發(fā)現(xiàn)工具箱里多出FCKeditor控件。
6.拖拽FCKeditor到頁面上
7.配置WebConfig
<?xml version="1.0"?>
<!--
??? 注意: 除了手動編輯此文件以外,您還可以使用
??? Web 管理工具來配置應用程序的設(shè)置。可以使用 Visual Studio 中的
???? “網(wǎng)站”->“Asp.Net 配置”選項。
??? 設(shè)置和注釋的完整列表在
??? machine.config.comments 中,該文件通常位于
??? /Windows/Microsoft.Net/Framework/v2.x/Config 中
-->
<configuration>
? <appSettings>
??? <add key="FCKeditor:BasePath" value="~/fckeditor/"/>
??? <add key="FCKeditor:UserFilesPath" value="/Files/" />
? </appSettings>
? <connectionStrings/>
?<system.web>
說明:BasePath是fckeditor所在路徑,fckeditor由于我們直接放網(wǎng)站目錄下這樣寫就可以,如果您的網(wǎng)站多放幾層適當調(diào)整即可。
??????????? UserFilesPath是所有上傳的文件的所在目錄。為什么要設(shè)置成/Files這樣而不是~/Files,因為FCKeditor使用這個值來返回你上傳后的文件的相對路徑到客戶端。否則的話客戶訪問的時候就會取客戶的機器目錄而不是http形式的目錄。
建議:Files要單獨做wwwroot目錄下的一個站點比較好,和我們的站點FCKEditor平行。不要把它放FCKEditor里,為什么呢?因為Files是要讓客戶有寫的權(quán)限的,如果放FCKEditor下很危險。
8.Files目錄要有寫的權(quán)限。你根據(jù)自己網(wǎng)站需求設(shè)置那個帳號,本文為方便設(shè)置User實際中你可能用ASP.NET帳號更合理。
?9.修改fckeditor/fckconfig.js文件
在第182行的位置
var _FileBrowserLanguage?= 'asp' ;?// asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage?= 'asp' ;?// asp | aspx | cfm | lasso | php
改為
var _FileBrowserLanguage?= 'aspx' ;?// asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage?= 'aspx' ;?// asp | aspx | cfm | lasso | php
10.FCKeditor給其瘦身。以_打頭的的都是范例文件或源文件,不過建議小心。
11.下面以上傳圖片示例說明如何使用,
點擊“瀏覽服務(wù)器”。
彈出窗口很容易報錯
如果報錯XML request error: Internal Server Error(500),很可能就是目錄路徑不對和寫權(quán)限沒有。
選擇圖像
最后效果
前臺代碼:
<%@ Page Language="C#"? validateRequest=false AutoEventWireup="true"? CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
??? <title>FCKeditor文本編輯器</title>
</head>
<body>
??? <form id="form1" runat="server">
??? <div>
??????? <fckeditorv2:fckeditor id="FCKeditor1" runat="server" DefaultLanguage="zh-cn" Height="400px" Width="660px"
></fckeditorv2:fckeditor>
???
??? </div>
??? </form>
</body>
</html>
怎么樣獲取結(jié)果呢?FCKeditor1.Value就是。
12.還有個類似的控件FreeTextBox也很好用,有興趣可以自己網(wǎng)上找找,比這個好用多了不過感覺沒這個好,而且它的最新版似乎收費了。
總結(jié)
以上是生活随笔為你收集整理的ASP.NET2.0 文本编辑器FCKeditor的冰冷之心 【月儿原创】的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 做一次活检多少钱
- 下一篇: .NET2.0隐形的翅膀,正则表达式搜魂