在asp.net 2.0中配置FCKeditor 2.6.4

 

FCKEditor asp.net设置

 

下载:http://www.fckeditor.net

(要下载FCKeditor2.6.zip和FCKeditor.NET2.5版的2个zip包)

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

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

下面结合一个ASP.NET2.0的项目来具体看看FCKeditor的安装、配置、使用。在开始之前请先下载FCKeditor文件包和FCKeditor.Net 服务器控件。启用VWD2005新建一个C#的WEB Site工程,取名FCKPro。

FCKeditor安装:

所谓安装就是一个简单的拷贝过程。把下载的FCKeditor2.4.2.zip文件包直接解压缩到FCKPro的根目录下,这样根目录下就得到一个FCKeditor文件夹,里面富含所有FCKeditor的核心文件。

然后把下载的FCKeditor.Net.zip随便解压缩到你硬盘的一个空目录,里面是FCKeditor.Net的源代码,你可以对它进行再度开发,本文尚不涉及本内容,我们只是直接使用其目录下的"bin"Debug目录中的FredCK.FCKeditorV2.dll文件。

VS2005中添加对FredCK.FCKeditorV2.dll的引用:

1.在FCKPro工程浏览器上右键,选择添加引用(Add Reference…),找到浏览(Browse)标签,然后定位到你解压好的FredCK.FCKeditorV2.dll,确认就可以了。这时,FCKPro工程目录下就多了一个bin文件夹,里面包含FredCK.FCKeditorV2.dll文件。当然,你也可以完全人工方式的来做,把FredCK.FCKeditorV2.dll直接拷贝到FCKPro"bin"下面,VS2005在编译时会自动把它编译进去的。

2.为了方便RAD开发,我们把FCKeditor控件也添加到VS的工具箱(Toolbox)上来,展开工具箱的常用标签组(General),右键选择组件(Choose Items…),在对话框上直接找到浏览按钮,定位FredCK.FCKeditorV2.dll,然后确认就可以了。这时工具箱呈现出控件的样子,这样会省去很多在开发时使用FCKeditor控件时要添加的声明代码。

至此,你已经完成了FCKeditor的安装,并可以在你的项目中使用FCKeditor了,当然后面还有很多需要配置的东西。

FCKeditor详细的设置:

进入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

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

修改

FCKConfig.DefaultLanguage = 'en' ;

FCKConfig.DefaultLanguage = 'zh-cn' ;

3、配置皮肤。有default、office2003、silver风格等,这里我们可以使用默认。

FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ;

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

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

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

修改

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'

6、编辑器域内默认的显示字体为12px,想要修改可以通过修改样式表来达到要求,打开/editor/css/fck_editorarea.css,修改font-size属性即可。如font-size: 14px;

7、关于安全性。

如果你的编辑器用在网站前台的话,那就不得不考虑安全了,在前台千万不要使用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']

] ;

这是我改过的Basic,把图像功能去掉,把添加链接功能去掉,因为图像和链接和flash和图像按钮添加功能都能让前台页直接访问和上传文件,要是这儿不改直接给你上传个木马还不马上玩完?

当然也可以配置一下WebConfig,也能让它确保安全,接下来我们将讲到。

FCKPro工程项目的设置:

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

<appSettings>

    <add key="FCKeditor:BasePath" value="/项目名称/fckeditor/"/>

   //Win2003下,Files目录一定要有IIS_WPG用户的写权限,否则可能无法上传

    <add key="FCKeditor:UserFilesPath" value="/项目名称/Files/" />

</appSettings>

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

2、在FCKpro工程项目中编写一个最简单的页面

如何获取其内容呢?读取FCKeditor1控件的Value属性值即可。

<%@ page language="C#" autoeventwireup="true" codefile="Default.aspx.cs" inherits="_Default" validaterequest="false" %>
<%@ register assembly="FredCK.FCKeditorV2" namespace="FredCK.FCKeditorV2" tagprefix="FCKeditorV2" %>
// 这里要主要两个参数 // 默认为<%@ page language="C#" autoeventwireup="true" codefile="Default.aspx.cs" inherits="_Default" %>
// 我们要添加一个参数 validateRequest=false,否则提交带html代码的内容会报错 // 从客户端(...)中检测到有潜在危险的 Request.Form 值。 <!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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
	<div>
		<fckeditorv2:fckeditor id="FCKeditor1" runat="server">
		</fckeditorv2:fckeditor>
		&nbsp;
	</div>
</form>
</body>
</html>

 

FCKEditor 2.6的问题:

1.FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"错误的解决办法

打开editor/filemanager/connectors/aspx/config.ascx修改CheckAuthentication()方法,返回true

C# code 

view plaincopy to clipboardprint?

  1. private bool CheckAuthentication()   
  2. {   
  3. // WARNING : DO NOT simply return "true". By doing so, you are allowing   

 

  1. // "anyone" to upload and list the files in your server. You must implement   
  2. // some kind of session validation here. Even something very simple as...   
  3. //   
  4. //        return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );   
  5. //   
  6. // ... where Session[ "IsAuthorized" ] is set to "true" as soon as the   
  7. // user logs in your system.    
  8.   
  9.         return true;   
  10. }  
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;
}

2.在上传文件窗口点击浏览服务器,会出现the server didn't send back a proper xml.....错误提示,因为后期版本的FCKEditor要求不同类型的文件分别传到不同的目录,包括file,image,falsh,media等目录,一定要先建立起来。

 

FCKeditor精简版的制作方法(附)

 进入FCKeditor文件夹,把所有“_”开头的文件和文件夹删掉,这些都是一些范例,只保留editor文件夹、fckconfig.js、fckeditor.js、fckstyles.xml、fcktemplates.xml就可以了;

  进入editor文件夹,删掉“_source”文件夹,里面放的同样是源文件;

  退回上一级目录进入filemanager文件夹,有browser和upload两个文件夹。进入browser"default"connectors,只保留aspx文件夹,其余的删掉;mcpuk目录亦可删除;upload也一样,只保留aspx文件夹;

  退到editor再进入images文件夹,smiley里面放的是表情图标,有msn和fun两个系列,如果你想用自己的表情图标,可以把它们都删除;如果你想用这里的表情图标那就不要删了;

  lang里面放的是语言包,如果只是用简体中文,那么只保留fcklanguagemanager.js、zh-cn.js两个文件就行了,建议也保留en.js(英文)、zh.js(繁体中文)两个文件,fcklanguagemanager.js是语言配置文件,有了它才能和fckconfig.js里的设置成对,对应上相应的语言文件,一定要保留!

  再退出lang文件夹,进入skins文件夹,如果你想使用FCKeditor默认的奶黄色,那就把除了default文件夹外的另两个文件夹直接删除,如果想用别的,那就看你自己的喜好了。

至此,文件精简完毕,由原来的2.55M变成现在的797K了。接着修改设置。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
CuteEditor for ASP.NET文版是建立在Html基础之上,最简单易用、功能最强大的所见即所得Asp.net在线编辑器。 CuteEditor可以帮助Asp.net开发者轻松的对原来文本框(Textarea)的内容(包括文字、图片等Html内容)进行编辑,更重要得是这些内容编辑的实现是所见即所得方式。 CuteEditor还集成了文件(包括图片、文档等)上传、媒体(包括视频、声音等,支持YouTube)文件直接插入等对你来说非常实用的功能模块。 对于商业授权用户,他们以完全自己进行操作升级和安全维护,我们制定了多种授权方式供广大用户选择。 CuteEditor功能特点 是什么使CuteEditor成为Html在线编辑器的领航者?除了其强大的功能和方便的使用, 这里还有一些顶尖的技术因素是CuteEditor编辑器成为你编辑和发布Web内容的最佳选择: 跨浏览器、跨平台的所见即所得网页编辑器 Compatible with the most important browsers available in the market: IE 5.5+, Firefox 1.0+, Mozilla 1.3+, Netscape 7+, Chrome and Safari (1.3+). This includes Macintosh and Linux. 界面简洁加载速度快 Numerous optimization methods has been applied. It's clean, compact, extremely fast-loading, but still powerful and efficient. CuteEditor遵循Web标准,没有类似 这种标签 Does your online html editor still use deprecated tags such as <FONT>? Cute Editor will help you build sites that adhere to the latest HTML standards, generates clean HTML/XHTML code with no deprecated tags. 能自动清理HTML代码Word标记 When text is pasted from Microsoft Word allot of unnecessary word specific markup is carried across. This can result in web pages that take an unnecessarily long time to download. The Paste from Word button solves this by removing word markup before pasting the text into your page. 对于开发人员来说简单易用 The perfect addition to your content management system! Only a couple lines of code , you don't need to be an expert. Allows you to add an online HTML editing functionality that works with standard HTML form. 很容易用API隐藏按钮和Tabs标记 Cute Editor allows developers to set the image directory, set the controls width, disable image uploading and deleting, restrict access to the source/preview tabs, hide buttons and lists that you don't want your clients to see or access. 高级表格管理 Create and modify tables and table cells. Set their border color, alignment, cellspacing and more! Once you've created a table, simply right click inside of it and use the handy popup menu to change its attributes. <caption>,<summary>,<thead>,<tfoot>,<th> tags are supported. 图片插入和自动上传 Built-in thumbnail generator. Thumbnail images are dynamically created; Supports upload new images. Paging - specify how many images. Support auto resize images. 用模板来管理内容 The basic idea behind a Content Management System (CMS) is to separate the management of content from design. Cute Editor allows the site designer to easily create and establish templates to give the site a uniform look. Templates may be modified when desired. 在线图像编辑 People that input content on a website are generally not web designers, so most don't have that design & technical fibre in them. With online image editor, you can now edit image file with no image editing software to download or install! Easy drag and drop familiar interface. Resize, change dimensions, scale, crop, add text, optimize, rotate, flip, mirror and add watermark. 把图片存储于数据库 With CuteEditor you can easily use a Sql Server database or access database as the file storage. RTF到HTML的相互转换 With CuteEditor you can easily convert an HTML document into an RTF file and RTF file into HTML or XHTML document. 创建PDF文件 CuteEditor also allows you dynamically create Adobe PDF documents from ASP.NET. 高级文件上传模式 We integrate a hi-performance ASP.NET upload component - Ajax uploader into Cute Editor. Ajax Uploader allows you to select and upload multiple files at once. It also supports client side validation of the file size/type before uploading.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值