当前位置导航:炫浪网>>网络学院>>网页制作>>ASP.NET教程

FCKeditor 2.6在ASP.NET中的配置方法

导读:

  FCKEditor目前的最新版本是2.6,但支持.NET的DLL版本还是2.5,本文介绍FCKEditor2.6在ASP.NET中的配置方法。

  本文的示例下载地址(包含了整个解决方案及网站,下载后即可使用):

  地址:http://www.china-aspx.com/Forum/showtopic-57.aspx

  FCKEditor官方下载地址:http://www.fckeditor.net/download

  配置方法如下:

  一、在官方网站上下载

  下载地址:http://sourceforge.net/project/downloading.php?group_id=75348&filename=FCKeditor_2.6.zip

  解压后目录结构如下图所示:

FCKeditor 2.6在ASP.NET中的配置方法(附源码下载)

  二、删除不必要的文件

  从官方下载下来的FCKEditor2.6大小有3.61M(解压后),其实有很多文件对于只用ASP.NET的来讲是不需要的,我们可以删除不必要的文件:

  1.根目录下除editor目录、fckconfig.js、fckeditor.js fckstyles.xml fcktemplates.xml 这几个保留,其余的全部删除

  2.editorfilemanagerconnectors目录中除aspx目录外全部删除

  3.editorlang目录中除en.js、zh.js 、zh-cn.js外全部删除

  4.删除_samples目录,当然如果你想看示例,就不要删除这个目录了。

  三、FCKEditor2.6的详细设置

  1.fckconfig.js中修改

  FCKConfig.ToolbarSets["Default"] = [
  ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
  ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
  ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
  ['Link','Unlink','Anchor'],
  ['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
  '/',
  ['Style','FontFormat','FontName','FontSize'],
  ['TextColor','BGColor'],
  ['FitWindow','ShowBlocks','-','About'] // No comma for the last row.
  ] ;
  //上面一段我去掉了一些不常用的功能,可以根据实际需要增加。
  FCKConfig.DefaultLanguage = 'zh-cn' ; //原来是en
  var _FileBrowserLanguage = 'aspx' ;// asp | aspx | cfm | lasso | perl | php | py 改成aspx
  var _QuickUploadLanguage = 'aspx' ;// asp | aspx | cfm | lasso | perl | php | py

  2.在Bin中加入DLL文件

  DLL文件下载地址:http://sourceforge.net/project/showfiles.php?group_id=75348&package_id=137125

  3.在工具栏中加入DLL文件

  4.配置上传路径

  编辑FCKeditoreditorfilemanagerconnectorsaspxconfig.aspx 中修改

  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; //原来这里是 false;不过还是建议看看上面的警告
  }

  在SetConfig方法中设置

  UserFilesPath = "~/Upload/FCKEditor";//我这里设置在了网站根目录下的Upload/FCKEditor目录中,根据实际情况和个人喜好而定。

FCKeditor2.4.2.zip是其最新的Javascript文件和图片什么的;
FCKeditor.NET.zip是ASP.NET调用的DLL在里面。

2.分别解压后把FCKeditor2.4.2.zip里的fckeditor目录整个复制到网站中。

3.解压FCKeditor.NET.zip包后在FCKeditor.Net_2.2\bin\Debug目录里找到FredCK.FCKeditorV2.dll。其他文件没用,把FredCK.FCKeditorV2.dll复制到我们的网站,建立一个Bin目录

4.引用FredCK.FCKeditorV2.dll。

配置WebConfig
<?xml version="1.0"?>
<!--
注意: 除了手动编辑此文件以外,您还可以使用
Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
“网站”->“Asp.Net 配置”选项。
设置和注释的完整列表在
machine.config.comments 中,该文件通常位于
\Windows\Microsoft.Net\Framework\v2.x\Config 中
-->
<configuration>
<appSettings>

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

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

</appSettings>

<connectionStrings/>
<system.web>

说明:BasePath是fckeditor所在路径,fckeditor由于我们直接放网站目录下这样写就可以,如果您的网站多放几层适当调整即可。
UserFilesPath所有上传的文件的所在目录。为什么要设置成/Files这样而不是~/Files因为FCKeditor使用这个值来返回你上传后的文件的相对路径到客户端。否则的话客户访问的时候就会取客户的机器目录而不是http形式的目录。

建议:Files要单独做wwwroot目录下的一个站点比较好,和我们的站点FCKEditor平行。不要把它放FCKEditor里,为什么呢?因为Files是要让客户有写的权限的,如果放FCKEditor下很危险。

相关内容
赞助商链接