.Net使用FCKEditor
下载
FCKeditor.net 分为两部分:静态部分与组件本分。
下载最新页面
http://www.fckeditor.net/download
下载源码
http://sourceforge.net/project/showfiles.php?group_id=75348&package_id=137125
解压缩下载包;编译源码,并生成组件。
安装配置
1、拷贝 "FredCK.FCKeditorV2.dll" 到BIN目录。拷贝fckeditor文件夹到站点跟目录;
2、用文本编辑器打开fckeditor/fckconfig.js文件,开始对编辑器进行配置;
var _FileBrowserLanguage = 'asp' ;
var _QuickUploadLanguage = 'asp' ;
改为
var _FileBrowserLanguage = 'aspx' ;
var _QuickUploadLanguage = 'aspx' ;
3、配置webConfig选项;
<appSettings>
<add key="FCKeditor:UserFilesPath" value="/UserFiles/" />
</appSettings>
4、在页面中使用控件
添加页面指令:<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
添加一个控件:<FCKeditorV2:FCKeditor ID="FCKeditor2" runat="server" DefaultLanguage="zh-cn" Height="400px"></FCKeditorV2:FCKeditor>
使用示例
自定义按钮
1、用文本编辑器打开fckeditor/fckconfig.js文件
2、拷贝FCKConfig.ToolbarSets["Basic"] = [['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About']] ;
改为:
FCKConfig.ToolbarSets["Myself"] = [['Bold','Italic','-','OrderedList','UnorderedList']] ;
3、设置控件的ToolbarSet属性。<FCKeditorV2:FCKeditor ID="FCKeditor2" ToolbarSet="Myself" runat="server"></FCKeditorV2:FCKeditor>
上传图片选项。
------------------------------------------------------------
配置上传路径
编辑FCKeditor"editor"filemanager"connectors"aspx"config.aspx 中修改
private bool CheckAuthentication()
{
return true;
}
在SetConfig方法中设置
UserFilesPath = "~/Upload/FCKEditor";//我这里设置在了网站根目录下的Upload/FCKEditor目录中,根据实际情况和个人喜好而定。
------------------------------------------------------------
换肤
系统提供了三种皮肤:default,office2003,silver; 在控件上设置SkinPath="editor/Skins/Default/";也可以通过程序完成设置
其它设置
在编辑器域内可以使用Tab键。(1为是,0为否) FCKConfig.TabSpaces = 0 ; 改为FCKConfig.TabSpaces = 1 ;
示例代码
fckeditor.aspx
<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeFile="fckeditor.aspx.cs" Inherits="fckeditor" %>
<%@ 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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
全部按钮<br />
<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" >
</FCKeditorV2:FCKeditor>
<br />
基本按钮<br />
<FCKeditorV2:FCKeditor ID="FCKeditor2" ToolbarSet="Basic" runat="server"></FCKeditorV2:FCKeditor>
<br />
精简按钮<br />
<FCKeditorV2:FCKeditor ID="FCKeditor3" ToolbarSet="Basic2" runat="server">
</FCKeditorV2:FCKeditor>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<br />
<a href="fckeditor/_samples/default.html">浏览更多示例</a>
</div>
</form>
</body>
</html>