天天看點

FreeTextBox4.0用法

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>

下面是工具欄按鈕的具體解釋: