ASP.NET2.0 文本编辑器FCKeditor

来源:互联网 发布:眼镜试戴软件 编辑:程序博客网 时间:2024/04/30 10:49

FCKeditor是目前最好的html文本编辑器,效果图:

1.FCKeditor的官方网站是:http://www.fckeditor.net/download 

要下载FCKeditor2.4.2.zip和   FCKeditor.NET版的2个zip包。

说明:
FCKeditor.zip是Javascript文件和图片等;
FCKeditor.NET.zip是ASP.NET调用的DLL在里面。

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

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

4.引用FredCK.FCKeditorV2.dll。
第一步:

第二步:

5.导入工具箱。
在“工具箱”下右键

 

点击“选择项”。弹出如图窗口:

点击浏览,找到dll所在目录。

 

 

这时发现工具箱里多出FCKeditor控件。

6.拖拽FCKeditor到页面上

7.配置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>

 

8.修改fckeditor/fckconfig.js文件

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

 

9.FCKeditor给其瘦身。以_打头的的都是范例文件或源文件,可以删除。

10.下面以上传图片示例说明如何使用,

点击“浏览服务器”。

 

 

弹出窗口

如果报错修改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;
 }

选择图像

最后效果

前台代码:

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

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

<!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" DefaultLanguage="zh-cn" Height="400px" Width="660px">
        </FCKeditorV2:FCKeditor>
   
    </div>
    </form>
</body>
</html>


获取结果
FCKeditor1.Value

原创粉丝点击