ASP.NET编辑器控件FreeTextBox的使用

 
FreeTextBox 是一个基于 Internet Explorer 中 MSHTML 技术的 ASP.NET 服务器控件。这是一款优秀的自由软件(Free Software),我们可以轻松地将其嵌入到 Web Forms 中实现 HTML 内容的在线编辑,在新闻发布、博客写作、论坛社区等多种 Web 系统中都会有用途。

官方网站:http://www.freetextbox.com/

FreeTextBox 1.6.3 (中文版)下载地址:http://www.percyboy.com/w/ftb/down/


1、复制 bin 目录下的 FreeTextBox.dll 文件到你的 Web 应用程序目录中的 bin 目录或其上层的虚拟目录下的 bin 目录;

2、把 - ftb.colorpicker.aspx
- ftb.imagegallery.aspx
- ftb.inserttable.aspx
从文件夹HelperScripts复制出来,放到外面与 - test.aspx (测试)同等级目录,
(不这么做,插入背景色,图片,表格就不好使),注意使用时要指定 HelperFilePath 属性;

3、把images文件夹放到test.aspx (测试)同等级目录下,来存放上传的图片.。(注意:用于存放上传图片的目录可以自定义取名字,但一定要放到虚拟目录的根目录,不能放到虚拟目录的子目录里面,并且设置ImageGalleryPath属性,设置文件夹名。)



4、在test.aspx 中,加图片的路径

<FTB:FreeTextBox id="FreeTextBox1" runat="server" Width="700" ButtonPath="\images\ftb\office2003\"/>



this.FreeTextBox1.Text 这个就是FTB中你输入的文本的内容,这是带HTML标记的



this.FreeTextBox1.HtmlStrippedText 这个是将HTML标记去掉的文本



5、写入数据库

在CSDN上看到朋友们说怎么把FreeTextBox内容写入数据库中

我做了一下.就是把所有产生的HTML代码都插入数据库的一个字段中

可以做一个新闻表

news

字段ID(自增) content addtime(getdate)

private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

if (!IsPostBack)

{

SqlConnection myConn = new SqlConnection("server=(local);database=mm;uid=sa;pwd=123");

SqlCommand myCmd = new SqlCommand("select * from test where id=2",myConn);

myConn.Open();

SqlDataReader myDr;

myDr=myCmd.ExecuteReader();

myDr.Read();

Response.Write(myDr["content"].ToString());

myDr.Close();

myConn.Close();

}

}



private void Button1_Click(object sender, System.EventArgs e)

{

SqlConnection myConn = new SqlConnection("server=(local);database=mm;uid=sa;pwd=123");

SqlCommand myCmd = new SqlCommand("insert into test (content) values('"+FreeTextBox1.Text+"')",myConn);

myConn.Open();

myCmd.ExecuteNonQuery();

myConn.Close();

}



[注]web.config

在system.web节加入:

<pages validateRequest="false"/>

原文地址:https://www.cnblogs.com/chaowei119/p/186289.html