1

我在我的 asp.net 和 vb.net Web 应用程序中集成了 ckeditor。以前这个网络应用程序使用的是 bootstrap-wysihtml5。但是现在客户需要使用ckeditor。

为了集成ckeditor,我做了以下事情:

我正在使用 ckeditor_4.4.1 。我已将 ckeditor 文件夹复制到根目录中。并将其链接到母版页中,如下所示。

   <%@ Master Language="VB" CodeFile="E4.master.vb" Inherits="_resx_E4" %>
   <!doctype html>
   <html lang="en">
   <head runat="server">
       <title></title>
       <meta name="robots" content="noindex, nofollow">
       <meta name="googlebot" content="noindex, nofollow">
       <link href='https://fonts.googleapis.com/css?family=Roboto:400,300,100' rel='stylesheet' type='text/css'>
       <script src="/ckeditor/ckeditor.js" type="text/javascript"></script>
   </head>

我没有更改内容页面的标题。就像下面这样

<%@ Page Page Title="" Language="VB" MasterPageFile="~/_resx/E4.master" AutoEventWireup="false" CodeFile="new.aspx.vb" Inherits="E4_Jobs_new" ValidateRequest="false" %>
<%@ Page    <%@ Register Src="~/_controls/ucApplicationQuestions.ascx" TagPrefix="Application"
TagName="Questions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">

最后是内容页面中的文本区号

<div><label>Description (required)</label>
  <div>
    <textarea runat="server" id="txtDescription" name="txtDescription" class="ckeditor" style="width: 98%; height: 250px;"  ></textarea>
  </div>
</div>

ckeditor 工具栏显示在 textarea 上。但是网站无法识别 ckeditor 字段中写入的值,也不会将这些值保存在数据库中。即使我在文本区域写完后提交表单,它也不允许我提交表单,因为描述字段必须有一些文本。但我实际上已经在 textarea 中写入或从 word 文件中复制粘贴。但它仍然没有任何价值。

请帮我写代码

4

1 回答 1

3

我找到了答案。我想我必须分享它;以防其他人面临同样的问题。

这是我遵循的步骤。

  1. 从链接 http://ckeditor.com/download下载了 ckeditor

  2. 复制项目文件夹下的整个文件夹。

  3. 在母版页中添加以下行以添加 ckeditor 的引用

    <script src="/ckeditor/ckeditor.js" type="text/javascript"></script>
    <script src="/ckeditor/adapters/jquery.js" type="text/javascript"></script>
    <script src="/ckeditor/ckeditor_custom.js" type="text/javascript"></script>
    
  4. 更改了特定文本区域的类

    <textarea runat="server" id="txtDescription" name="txtDescription" class="ckeditor" style="width: 98%; height: 250px;"   ></textarea>
    
  5. 在内容页面底部添加了以下javascript函数

    $('#' + '<%= btnSave.ClientID%>').mousedown(function () {
     for (var i in CKEDITOR.instances) {
         CKEDITOR.instances[i].updateElement();
     }
    });
    

就是这样。

这里 btn.save 是提交数据的按钮

谢谢

于 2014-06-11T12:36:42.797 回答