【问题标题】:How To Implement Rich Text Editor [closed]如何实现富文本编辑器 [关闭]
【发布时间】:2013-08-27 01:26:19
【问题描述】:

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

【问题讨论】:

  • 您是否研究过任何现有的富文本编辑器?您正在处理特定的文件格式吗?一般来说,我想你会使用现成的富文本编辑器(有很多可用的)并将其内容设置为文件的内容,让用户编辑,然后用编辑器内容替换文件内容保存。你开始尝试了吗?
  • 我一直在寻找这个,但我找不到实现富文本编辑器的代码。我希望我的富文本编辑器可以读取所有文件格式。但是对于现成的我还没有尝试这个。我会使用你的建议先生。谢谢你
  • 查看CKEditor
  • 关于实现富文本编辑器的好信息

标签: asp.net vb.net rich-text-editor


【解决方案1】:
【解决方案2】:
 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();
      }
   }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-04
    • 2010-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多