FreeTextBox4.0用法

来源:互联网 发布:淘宝视频营销 编辑:程序博客网 时间:2024/05/23 00:04

FreeTextBox是一个免费的、广泛应用于Asp.Net的新闻发布系统和博客中的一个控件;FreeTextBox类似于微软的RTF控件。可以设置字体、颜色、插入图片、建立超级链接、插入表格等操作,功能十分强大。到目前我发现最新的版本为4.0 beta1版,使用方法也比较简单。

一、下载FreeTextBox文件。(单击这里下载)

二、解压后,把【Asp.Net】文件夹中的【2.0】文件夹里面的Refresh.Web.FreeTextBox.dll文件复制到你站点中的【Bin】文件夹里。复制【Refresh_Web】文件夹到你的站点根目录下。

三、添加引用

在Vs2005的解决方案窗口中单击右键,选择“添加引用”命令,在弹出的对话框中单击浏览选项卡,找到站点文件夹中Bin里面的Refresh.Web.FreeTextBox.dll文件,单击确定。



把Refresh.Web.FreeTextBox.dll动链文件直接拖动到工具栏的“常规”选项卡中,这时在常规选项卡里会出现三个按钮:ToolBar、floatie和FreeTextBox。

 

 

三、新建一个页面Default.Aspx,把FreeTextBox拖放到页面中。

四、设置FreeTextBox控件的工具栏,切换页面至源代码视图。

 

五、将输入的结果存储到数据库中

创建Sql Server数据库表 NEWS,其中包括一个Neirong字段nText类型。

在页面上添加一个命令按钮,命名为【提交】。在【提交】按钮的单击事件中添加代码。

添加引用:Using System.Data.SqlClient;

protected void Button1_Click(object sender, EventArgs e)//【提交按钮】
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
        SqlCommand com = new SqlCommand("Insert into News(neirong) values(@neirong)", con);
        con.Open();
        com.Parameters.AddWithValue("@neirong", FreeTextBox1.Text);
        com.ExecuteNonQuery();
        con.Close();
    }

六、显示Neirong字段中的内容

新建一个页面,添加一个Label1标签,在Load事件中添加读取数据库信息的代码

Using System.Data.SqlClient;

 protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con=new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
        SqlCommand com=new SqlCommand("select neirong from news where id=1",con);
        con.Open();
        SqlDataReader dr=com.ExecuteReader();
        if (dr.Read())
        {
              Label1.Text = dr["neirong"].ToString();
        }
        con.Close();

    }

这样就能够显示出在FreeTextBox控件中输入的内容。

FTB:FreeTextBox id="FreeTextBox1" runat="SErver" Width="900px" Height="500px" Theme="office12"

     IsFullDocument="true"> 在这段代码后面插入下列代码,用来设置显示的工具栏按钮。

         <FTB:ToolbarGroup Title="Font" >

              <FTB:ToolbarItem Name="ParagraphMenu" />

              <FTB:ToolbarItem Name="FontFacesList" />

              <FTB:ToolbarItem Name="FontSizesList" />

              <FTB:ToolbarItem Name="break" />

              <FTB:ToolbarItem Name="Bold" />

              <FTB:ToolbarItem Name="Italic" />

              <FTB:ToolbarItem Name="Underline" />

              <FTB:ToolbarItem Name="Strikethrough" />

              <FTB:ToolbarItem Name="separator" />          

              <FTB:ToolbarItem Name="Superscript" />

              <FTB:ToolbarItem Name="Subscript" />

              <FTB:ToolbarItem Name="separator" />

              <FTB:ToolbarItem Name="FontForeColorPicker" />

              <FTB:ToolbarItem Name="FontBackColorPicker" />

         </FTB:ToolbarGroup>        

         <FTB:ToolbarGroup Title="Format">

              <FTB:ToolbarItem Name="BulletedList" />

              <FTB:ToolbarItem Name="NumberedList" />

              <FTB:ToolbarItem Name="Indent" />

              <FTB:ToolbarItem Name="Outdent" />

              <FTB:ToolbarItem Name="break" />

              <FTB:ToolbarItem Name="JustifyLeft" />

              <FTB:ToolbarItem Name="JustifyRight" />

              <FTB:ToolbarItem Name="JustifyCenter" /> 

              <FTB:ToolbarItem Name="JustifyFull" />

         </FTB:ToolbarGroup>        

         <FTB:ToolbarGroup Title="Edit">

              <FTB:ToolbarItem Name="Cut" />

              <FTB:ToolbarItem Name="Copy" />

              <FTB:ToolbarItem Name="Paste" />    

              <FTB:ToolbarItem Name="PasteFromWord" />

              <FTB:ToolbarItem Name="PasteCode" />          

              <FTB:ToolbarItem Name="break" />

              <FTB:ToolbarItem Name="Undo" />

              <FTB:ToolbarItem Name="Redo" />          

              <FTB:ToolbarItem Name="Print" />

              <FTB:ToolbarItem Name="Save" />

              <FTB:ToolbarItem Name="Clear" />

         </FTB:ToolbarGroup>        

         <FTB:ToolbarGroup Title="Table">

              <FTB:ToolbarItem Name="InsertTable" />

              <FTB:ToolbarItem Name="InsertTableColumnBefore" />          

              <FTB:ToolbarItem Name="InsertTableColumnAfter" />

              <FTB:ToolbarItem Name="InsertTableRowBefore" />             

              <FTB:ToolbarItem Name="InsertTableRowAfter" />

              <FTB:ToolbarItem Name="break" />

              <FTB:ToolbarItem Name="DeleteTableColumn" />

              <FTB:ToolbarItem Name="DeleteTableRow" />

              <FTB:ToolbarItem Name="MergeCells" />

              <FTB:ToolbarItem Name="SplitCell" />

         </FTB:ToolbarGroup>        

         <FTB:ToolbarGroup Title="CSS">

              <FTB:ToolbarItem Name="CssClass" />

              <FTB:ToolbarItem Name="EditCssProperties" />  

              <FTB:ToolbarItem Name="WordClean" />

              <FTB:ToolbarItem Name="break" />              

              <FTB:ToolbarItem Name="CssClassList" >

                   <FTB:ToolbarListItem Text="<span class='sampleClass'>Sample Class</span>" Value="sampleClass" />

              </FTB:ToolbarItem>

         </FTB:ToolbarGroup>        

         <FTB:ToolbarGroup Title="Insert">

              <FTB:ToolbarItem Name="InsertRule" />

              <FTB:ToolbarItem Name="InsertImage" />            

              <FTB:ToolbarItem Name="CreateLink" />

              <FTB:ToolbarItem Name="Unlink" />

              <FTB:ToolbarItem Name="break" />         

              <FTB:ToolbarItem Name="InsertHtmlMenu">

                   <FTB:ToolbarListItem Value="<b>some bold text</b>" Text="<b>bold text</b>" />

                   <FTB:ToolbarListItem Value="<b>some italic text</b>" Text="<i>italic text</i>" />

              </FTB:ToolbarItem>

         </FTB:ToolbarGroup>        

</FTB:FreeTextBox>(这句不用输入)

 

 

<FTB:Floatie ID="Floatie1" TargetEditor="FreeTextBox1" runat="SErver">

     <FTB:ToolbarGroup >

         <FTB:ToolbarItem Name="ParagraphMenu" />

         <FTB:ToolbarItem Name="BulletedList" />

         <FTB:ToolbarItem Name="NumberedList" />

         <FTB:ToolbarItem Name="break" />

         <FTB:ToolbarItem Name="CreateLink" />

         <FTB:ToolbarItem Name="Bold" />

         <FTB:ToolbarItem Name="Italic" />

         <FTB:ToolbarItem Name="Underline" />

         <FTB:ToolbarItem Name="Strikethrough" />

         <FTB:ToolbarItem Name="separator" />          

         <FTB:ToolbarItem Name="Superscript" />

         <FTB:ToolbarItem Name="Subscript" />

     </FTB:ToolbarGroup>Bold  加粗
BulletedList 项目符号
Copy  复制
CreateLink  插入链接
Cut   剪切
Delete  删除
DeleteTableColumn 删除一列(En)
DeleteTableRow  删除一行(En)
IeSpellCheck IE拼写检查(En 需要安装拼写检查软件)
Indent  增加缩进
InsertDate 插入日期
InsertImage 插入图片
InsertRule 插入水平线(En)
InsertTable 插入表格(En)
InsertTableColumnAfter 插入表格列在后面(En)
InsertTableColumnBefore 插入表格列在前面(En)
InsertTableRowAfter 插入表格行在后面(En)
InsertTableRowBefore 插入表格行在前面(En)
InsertTime 插入时间
Italic 斜体
JustifyCenter 居中
JustifyFull 两端对齐
JustifyLeft 左对齐
JustifyRight 右对齐
NetSpell 网络拼写检查(En)
NumberedList 编号
Outdent 减少缩进
Paste 粘贴
Print 打印
Redo  重复
RemoveFormat 删除所有格式
Save  保存(En)
StrikeThrough  删除线
SubScript 下标
SuperScript 上标
Underline 下划线
Undo  撤消
Unlink  删除链接

</FTB:Floatie>

下面是工具栏按钮的具体解释: