ASP.NET2.0 文字編輯器FCKeditor使用方法詳解

來源:互聯網
上載者:User

FCKeditor是目前最好的html文字編輯器,如果還不明白的話看了就知道了
:

那麼為什麼說是FCKeditor的冰冷之心呢?這不是嘩眾取寵,主要是說它使用起來有點麻煩,下文就詳細說明如何搞定這玩意兒。

1.FCKeditor的官方網站是: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調用的DLL在裡面。

2.分別解壓後把FCKeditor2.4.2.zip裡的fckeditor目錄整個複製到網站中。

3.解壓FCKeditor.NET.zip包後在FCKeditor.Net_2.2/bin/Debug目錄裡找到FredCK.FCKeditorV2.dll。其他檔案沒用,把FredCK.FCKeditorV2.dll複製到我們的網站,建立一個Bin目錄

4.引用FredCK.FCKeditorV2.dll。
第一步:

第二步:

5.匯入工具箱。
在“工具箱”下右鍵

點擊“選擇項”。快顯視窗:

點擊瀏覽,找到dll所在目錄。

這時發現工具箱裡多出FCKeditor控制項。

6.拖拽FCKeditor到頁面上

7.配置WebConfig
<?xml version="1.0"?>
<!--
    注意: 除了手動編輯此檔案以外,您還可以使用
    Web 管理工具來配置應用程式的設定。可以使用 Visual Studio 中的
     “網站”->“Asp.Net 配置”選項。
    設定和注釋的完整列表在
    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由於我們直接放網站目錄下這樣寫就可以,如果您的網站多放幾層適當調整即可。
            UserFilesPath是所有上傳的檔案的所在目錄。為什麼要設定成/Files這樣而不是~/Files,因為FCKeditor使用這個值來返回你上傳後的檔案的相對路徑到用戶端。否則的話客戶訪問的時候就會取客戶的機器目錄而不是http形式的目錄。

建議:Files要單獨做wwwroot目錄下的一個網站比較好,和我們的網站FCKEditor平行。不要把它放FCKEditor裡,為什麼呢?因為Files是要讓客戶有寫的許可權的,如果放FCKEditor下很危險。

8.Files目錄要有寫的許可權。你根據自己網站需求設定那個帳號,本文為方便設定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.下面以上傳圖片樣本說明如何使用,

點擊“瀏覽伺服器”。

快顯視窗很容易報錯

如果報錯XML request error: Internal Server Error(500),很可能就是目錄路徑不對和寫入權限沒有。

選擇映像



最後效果

前台代碼:

<%@ 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>

怎麼樣擷取結果呢?FCKeditor1.Value就是。

12.還有個類似的控制項FreeTextBox也很好用,有興趣可以自己網上找找,比這個好用多了不過感覺沒這個好,而且它的最新版似乎收費了。

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.