ASP.NET HTML编辑器

时间:2014-07-17 09:36:33

标签: asp.net webforms html-editor

我在向asp.net网络表单添加Html编辑器时遇到了一些问题。在管理面板中,我想将Html编辑器添加到我的文本区域,以便建立一个很酷的用户界面。我有.aspx如:

<%@ Page Title="" Language="C#" MasterPageFile="~/admin/IncubatorAdmin.master" 
  AutoEventWireup="true" CodeFile="AddFAQ.aspx.cs" Inherits="admin_AddFAQ" %>
 <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <section id="main" class="column">
 <article class="module width_full">
          <header><h3>Post FAQ </h3></header>
              <div class="module_content">
        <fieldset style="width: 60%; float: left; margin-right: 3%;">
          <label>Content</label>
            <asp:TextBox ID="txtContent" TextMode="MultiLine" Columns="50" Rows="20" runat="server"/>
         </fieldset>
        <asp:Label ID="ResultLabel" runat="server" Text=""></asp:Label>
                      <div class="clear"></div>
              </div>
          <footer>
              <div class="submit_link">
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" 
          Text="Publish FAQ" class="alt_btn" />               
              </div>
          </footer>
      </article><!-- end of post new article -->
 </section>

和C#代码:

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

public partial class admin_AddFAQ : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack)
        return;

    String cs = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

    using (MySqlConnection cn = new MySqlConnection(cs))
    {
        MySqlCommand command = new MySqlCommand(StoredProcedures.select_faq, cn);
        command.CommandType = CommandType.StoredProcedure;

        int fid = 1;
        command.Parameters.AddWithValue("fid", fid);
        command.Parameters["fid"].Direction = ParameterDirection.Input;
        cn.Open();

        MySqlDataReader reader = command.ExecuteReader();

        while (reader.Read())
        {
             txtContent.Text = (String)reader[1];
        }
        reader.Close();
        cn.Close();
    }
}

protected void Button1_Click(object sender, EventArgs e)
{
    String cs = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

    using (MySqlConnection cn = new MySqlConnection(cs))
    {
        MySqlCommand command = new MySqlCommand(StoredProcedures.update_faq, cn);
        command.CommandType = CommandType.StoredProcedure;

        int fid = 1;
        command.Parameters.AddWithValue("fid", fid);
        command.Parameters["fid"].Direction = ParameterDirection.Input;
        command.Parameters.AddWithValue("fcontent", txtContent.Text);
        command.Parameters["fcontent"].Direction = ParameterDirection.Input;

        cn.Open();
        if (command.ExecuteNonQuery() > 0)
        {
            ResultLabel.Text = "";
            ResultLabel.Text = "FAQ page successfully updated";
        }
        cn.Close();
    }
}

}

我应该对.aspx,c#和web.config做些什么改变?请帮助我......

1 个答案:

答案 0 :(得分:0)