我在我的ASP.NET和VB.NET Web应用程序中集成了CKEditor。此前,此Web Appilication正在使用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文件复制粘贴。但它仍然没有得到任何价值。

请帮我使用代码

有帮助吗?

解决方案

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

以下是我跟随的步骤。

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

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

  3. 在主页上添加了以下行以添加CKEDITORS

    的参考
    <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的类

    <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();
     }
    });
    
  6. 这是它。

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

    感谢

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top