强大的 FCK编辑器 c#

        最近做了个网站里面有发布图文并茂的文章,在网上就找到了这个文本编辑器。用的时候出现N多的问题。在此总结下心德,仅供大家参考。

 首先,下载这连个文件。

FCKeditor2.4.2.zip 是其最新的Javascript 文件和图片等;

FCKeditor.NET.zip 是一个 ASP.NET 控件 DLL 文件 。

在下载上面的文件之前先用c#2005/2008建立个 Website工程,取名FCKProtect。

其次就是:FCK的安装,安装的过程也就是拷贝的过程,把解压后的  FCKeditor2.4.2.zip 文件放到工程的根目录下。在把解压     FCKeditor.NET.zip后文件bin目录里debug下的FredCK.FCKeditorV2.dll复制到项目中的bin目录下,编译下就可以使用。也可以右击工程添加引用FCKeditor.NET.zip解压得到的FredCK.FCKeditorV2.dll同样在bin目录中也会出现FredCK.FCKeditorV2.dll。就可以使用了。

FCK的配置:

进入 FCKeditor 文件夹,编辑 fckconfig.js 文件。

1.是必须的,也是非常重要的 。

修改

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

5.关于安全性。

如果你的编辑器用在网站前台的话,那就不得不考虑安全了,在前台千万不要使用 Default 的 toolbar ,要么自定义一下功能,要么就用系统已经定义好的 Basic ,也就是基本的 toolbar ,

修改

FCKConfig.ToolbarSets["Basic" ] = [

    ['Bold' ,'Italic' ,'-' ,'OrderedList' ,'UnorderedList' ,'-' ,'Link' ,'Unlink' ,'-' ,'About' ]

FCKConfig.ToolbarSets["Basic"] = [

['Bold','Italic','-','OrderedList','UnorderedList','-',/*'Link',*/'Unlink','-','Style','FontSize','TextColor','BGColor','-','Smiley','SpecialChar','Replace','Preview']

] ;

 6.解决500错误 

进入fckeditor/editor/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;
 }

修改为:

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

7.webconfig 的配置:

配置WebConfig ,在<appSettings> 节点添加,如下所示:

 <appSettings>

    <add key="FCKeditor:BasePath" value="~/fckeditor/"/>

    <add key="FCKeditor:UserFilesPath" value="/ Files/" />

</appSettings>

说明:BasePath 是fckeditor 所在路径,fckeditor 由于我们直接放网站目录下这样写就可以,如果您的网站多放几层适当调整即可。UserFilesPath 是所有上传的文件的所在目录。我们新建了一个Files 文件夹放在了项目中做为上传文件的所在目录,这里为了方便,但由于考虑到安全性,我们建议Files 要单独做wwwroot 目录下的一个站点比较好,和我们的站点FCKEditor 平行。不要把它放FCKEditor 里,为什么呢?因为Files 是要让客户有写的权限的,如果放FCKEditor 下很危险。Files 目录要有写的权限。你根据自己网站需求设置那个帐号,本文为方便设置User 实际中你可能用ASP.NET 帐号更合理。

8.制作一个简单的页面

<% @ Page Language ="C#"  AutoEventWireup ="true"    CodeFile ="Default.aspx.cs"  Inherits ="_Default" validateRequest ="false"  %>

 

<% @ Register Assembly ="FredCK.FCKeditorV2" Namespace ="FredCK.FCKeditorV2" TagPrefix ="FCKeditorV2" %

注:要设置validateRequest  为false,不然提交带 html 代码的内容会报错。

< body >

    < form id ="form1" runat ="server">

    < div >

        < FCKeditorV2 : FCKeditor ID ="FCKeditor1" runat ="server">

        </ FCKeditorV2 : FCKeditor >

        &nbsp; </ div >

    </ form >

</ body >

至此,文件配置使用完毕,可以松口气了。

2 、配置语言包。有英文、繁体中文等,这里我们使用简体中文。

修改

FCKConfig.DefaultLanguage = 'en' ;

FCKConfig.DefaultLanguage = 'zh-cn' ;

3 、在编辑器域内可以使用Tab 键。(1 为是,0 为否)

FCKConfig.TabSpaces = 0 ; 改为FCKConfig.TabSpaces = 1 ;

4 、加上几种我们常用的字体的方法,例如:

修改

FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;

FCKConfig.FontNames = ' 宋体 ; 黑体 ; 隶书 ; 楷体 _GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana'

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值