Pergunta

I want to implement rich text editor in my project, the situation is when user click the file,the file will open in the text editor.I use vb.net and asp.net. someone have idea please help me..

Outras dicas

 Firstly download the ckeditor from 

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

then copy the ckeditor folder and paste it in your asp.net website.


 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();
      }
   }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top