4

我想在我的项目中实现富文本编辑器,情况是当用户单击文件时,文件将在文本编辑器中打开。我使用 vb.net 和 asp.net。有人有想法请帮助我..

4

2 回答 2

0

这是示例:

带有 ASP.NET 的富文本编辑器

使用 HTML 富文本编辑器的示例 - Cleditor

于 2013-08-27T02:59:00.667 回答
0
 Firstly download the ckeditor from 

https://ckeditor.com/ckeditor-4/download/

然后复制 ckeditor 文件夹并将其粘贴到您的 asp.net 网站中。


 Add the script <script src="ckeditor/ckeditor.js"></script> in the header 
 section '<head></head>'.

 Make sure that in <%@ %> part ValidateRequest is set false . In .NET 4 you 
 may need to do a little more. Sometimes it's necessary to also add 
 
 <httpRuntime requestValidationMode="2.0" /> 

  to web.config.

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

<!DOCTYPE>

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
 <script  type="text/javascript" src="ckeditor/ckeditor.js"></script>
 <title></title>
</head>
<body>
 <form id="form1" runat="server">
 <div>
 <asp:TextBox ID="text" runat="server" TextMode="MultiLine"></asp:TextBox>
 <script>
   CKEDITOR.replace("text"); 
 </script> 

    <asp:Button ID="Button1" runat="server" Text="save" OnClick="save"  />
     <asp:Button ID="Button2" runat="server" Text="show" OnClick="showData"  />
   
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
   
 </div>
 </form> 
</body>
</html>

In aspx.cs file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
   SqlConnection cn = new SqlConnection();
   protected void Page_Load(object sender, EventArgs e)
   {
      Label1.Text = "";
      cn.ConnectionString = "ConnectionString";
   }
   protected void save(object sender, EventArgs e)
   {
      cn.Open();
      SqlCommand cmd = new SqlCommand("INSERT INTO new (data) values (@data)" , cn);
      cmd.Parameters.AddWithValue("@data",text.Text);
      cmd.ExecuteNonQuery();
      text.Text = "";
      cn.Close();

    }

     protected void showData(object sender, EventArgs e)
     {
        cn.Open();
        SqlCommand cmd = new SqlCommand("SELECT data from new where id = 14", cn);
        Label1.Text = cmd.ExecuteScalar().ToString();
        cn.Close();
      }
   }
于 2020-07-28T15:48:26.803 回答