asp.net FCKeditor 使用教程

首先下载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文件。

创建一个新的文件夹取名叫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浏览服务器文件夹的位置代码如下:

  <appSettings>
    <add  key="FCKeditor:UserFilesPath" value="/fckeditor/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/aspx/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 = "/fckeditor/userfiles/";该方法也是设置上传的文件夹路径,最好与web.config中设置相同。

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

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

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

 

这款编辑器,在处理图片的时候是在编辑使用图片的时候,使用的是相对路径,例如:/imges/test.jpg

但是他在处理名称相同的时候是重新命名

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章