Ckeditor值不能被asp.net和vb.net识别

ckeditor value is not recognized by asp.net and vb.net

本文关键字:net 识别 vb asp 不能 Ckeditor      更新时间:2023-09-26

我已经在我的asp.net和vb.net web应用程序中集成了ckeditor。之前这个web应用程序使用的是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字段中写入的值,也不会将这些值保存在数据库中。即使当我在文本区域上写完后提交表单,它也不允许我提交表单,因为描述字段必须有一些文本。但我实际上是在文本区写的或者是从word文件复制粘贴的。但它仍然没有得到任何值。

请帮我写代码

我找到了答案。我想我必须和大家分享;以防别人遇到同样的问题。

以下是我所遵循的步骤。

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

  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是提交数据的按钮

谢谢