您的位置:首页 > 编程语言 > ASP

ASP.NET使用FCKEditor_2.6.6与FCKeditor.Net_2.6.3配置

2010-06-27 00:43 507 查看
首先下载FCKEditor插件

下载网址:http://www.fckeditor.com/

这里需要下载2种文件

1.下载FCKeditor_2.6.6,fckeditor应用程序的相关文件。

2.下载FCKeditor.Net_2.6.3,asp.net程序需要的dll文件。

然后创建一个web项目,将下载压缩文件解压。将fckeditor文件,夹拷贝到项目,删除多余的文件,只保留 editor文件夹,fckconfig.js,fckeditor.js,fckstyles.xml,fcktemplate.xml文件。

在web项目根目录下边创建一个新的文件夹取名叫userfiles用于存储本地上传到服务器的文件,也是fckeditor浏览服务器文件的位置(文件夹位置和名称根据个人喜好决定)。

接下来进行fckeditor项目的配置

1.引入FredCK.FCKeditorV2.dll文件,该文件位于Fckeditor.net_2.6.3/bin/release/2.0/下。

2.在工具栏引用fckeditor控件,工具栏中右键-选择项-.net framework组件-浏览-选择刚才引用的FredCK.FCKeditorV2.dll文件(最好引用项目下FredCK.FCKeditorV2.dll文件)。

3.将控件拖到页面产生如下代码:

<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" BasePath="/fckeditor/" Width="800px" Height="300px"></FCKeditorV2:FCKeditor>

注意:BasePath属性不是自动生成,需要自己手动添加fckeditor应用程序文件夹路径,该路径可以配置在web.config中,文件夹所在项目位置不同,路径配置也不同根据实际情况而定,

如果路径配置不正确页面将无法显示编辑器。

4.配置userfiles用于存储本地上传到服务器的文件,即fckeditor浏览服务器文件夹的位置代码如下,可以加到你的项目的web.config文件中:

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

5.配置fckconfig.js中 FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ;用设置fckeditor编辑器的皮肤,一般不用修改。

6.配置fckconfig.js中 FCKConfig.DefaultLanguage 将默认值 en 改为 zh-cn。

代码如下:FCKConfig.DefaultLanguage = 'zh-cn' ;

7.配置fckconfig.js中var _FileBrowserLanguage 和 var _QuickUploadLanguage 将默认值 php 改为 aspx

代码如下:var _FileBrowserLanguage = 'aspx' ;

var _QuickUploadLanguage = 'aspx' ;

8.配置fckeditor/filemanager/connectors/asp/config.ascx文件,

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

该方法用于验证用户是否具有上传文件的权限,默认return false,这里我们将false改为true。

9.配置config.ascx文件中的SetConfig方法中: UserFilesPath = "/userfiles/";该方法也是设置上传的文件夹路径,最好与web.config中设置相同。

10.如果使用时候出现,例如具有现在危险Request.Form的值,已从客户端侦测。

请加入页面page标签中加入 ValidateRuqest=false;

代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FCKEditor._Default" ValidateRequest="false" %>

11.后台加载及读取内容的时候最都用FCKeditor1.Value,如果读取编辑器中的内容时不要用Request.Form["FCKeditor1"].Value,否则再次加载的时候将不能正常显示。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: