---
title: "FCKeditor(asp.net)使用方法"
author: "xiaodongdong"
date: "2010-10-27T03:36:08Z"
tags: []
categories: ["编程语言"]
slug: "fckeditor-asp-net"
draft: false
lastmod: "2010-10-27T03:36:08Z"
id: 795099
url: "https://xiaodongdong.iteye.com/blog/795099"
---

FCKeditor   
FCK的组成:   
1.FCK核心文件(包括图片,JS...)   
2.FCK.NET文件(就一个dll,名字叫FredCK.FCKeditorV2.dll) 

FCK的安装   
官方网站[http://www.fckeditor.net/](http://www.fckeditor.net/)   
官方文档[http://wiki.fckeditor.net/](http://wiki.fckeditor.net/) 

FCK的安装   
下载回来以后,将两个文件分别解压,核心文件夹里的.js和.xml以及editor文件夹不要动,其他的文件嘛可以删除,不过我们不建议你这么做..因为FCK是适合很多语言的(比如asp,php...)所以一看就知道,其他文件就是用来做别的语言的工作的..   
.net里的只有一个dll文件,在 FCKeditor.Net\_2.2\\bin\\Debug目录下的FredCK.FCKeditorV2.dll...   
修改fckconfig.js中的以下部分,将两行的asp都改成aspx... 

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

打开FCKPro工程的Web. Config文件，修改appSettings元素，配置如下：   
&lt;appSettings&gt;   
&lt;add key="FCKeditor:BasePath"value="~/FCKeditor/"/&gt;   
&lt;add key="FCKeditor:UserFilesPath"value="/FCKPro/Files" /&gt;   
&lt;/appSettings&gt;   
配置Web.Config的目的在于我们想使用它强大的文件上传功能... 

在工程中引用此dll,并在控件中也引用进来,这样就可以使用它了.. 

至于如何获取它的内容,很简单,就一句话FCKeditor1.Value就可以了 

FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"错误的解决办法   
我最近在整合FCK,我也遇到了这个问题。 

解决办法： 

打开editor/filemanager/connectors/aspx/config.ascx修改CheckAuthentication()方法，返回true 

C# code 

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 true;  
} 

随便看了一下config.ascx里的内容，发现如果想让对每个用户进行不同的配置，FCKeditor支持的更好了。

 

 

怎么加载FCKeditor我就不多说了，随便一搜就一大把，说点心得吧。

FCKeditor的功能太强大了，很多功能都用不到，还占用很多空间，那怎么把不用的功能都删掉呢？

在fckconfig.js中，修改以下部分

FCKConfig.ToolbarSets\["Default"] = [  
    // No comma for the last row.  
] ;

 

附：

/* Source="页面源码"

　　DocProps="页面属性"

　　Save＝"保存"

　　NewPage="新建"

　　Preview="预览"

　　Templates="模版"

　　Cut="剪切"

　　Copy="拷贝"

　　Paste="粘贴"

　　PasteText="粘贴为无格式的文本"

　　PasteWord="粘贴Word格式"

　　Print="打印"

　　SpellCheck="拼写检查,要装插件"

　　Undo="撤消"

　　Redo="重做"

　　Find="查找"

　　Replace="替换"

　　SelectAll="全选"

　　RemoveFormat="清除格式(清除现在文本的格式)"

　　Form="表单域"

　　Checkbox="复选"

　　Radio="单选"

　　TextField="单行文本"

　　Textarea="多行文本"

　　Select="列表"

　　Button="按钮"

　　ImageButton="图像区域"

　　HiddenField="隐藏域"

　　Bold="加粗"

　　Italic="倾斜"

　　Underline="下划线"

　　StrikeThrough="删除线"

　　Subscript="下标"

　　Superscript="上标"

　　OrderedList="删除/插入项目列表"

　　UnorderedList="删除/插入项目符号"

　　Outdent="减少缩进"

　　Indent="增加缩进"

　　JustifyLeft="左对齐"

　　JustifyCenter="居中对齐"

　　JustifyRight="右对齐"

　　JustifyFull="分散对齐"

　　Link="链接"

　　Unlink="删除链接"

　　Anchor="插入/删除锚点"

　　Image="上传图片"

　　Flash="上传动画"

　　Table="插入表格"

　　Rule="插入水平线"

　　Smiley="插入表情"

　　SpecialChar="插入特殊字符"

　　PageBreak="插入分页符"

　　Style="样式"

　　FontFormat="格式"

　　FontName="字体"

　　FontSize="大小"

　　TextColor="字体颜色"

　　BGColor="背景色"

　　FitWindow="全屏编辑"

　　About="关于我们"

 

由于FCKeditor是把网页格式写入到数据库中，所以读出来显示的控件必须支持html格式，我使用的是用&lt;div&gt;显示读出的数据，将&lt;div runat="server"&gt;设置成服务器控件，将内容赋值给div.InnerHtml属性即可；显示数据的页面一定要加入&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="\*.aspx.cs" Inherits="\*" validateRequest="false"%&gt;这句，否则会报错。