本文轉自http://blog.csdn.net/JOHNCOOLS/archive/2006/04/08/655553.aspx感謝作者們的付出---------------版本: FreeTextBox 3.1.1 asp.net1.11.下載 FreeTextBox 3.1.1 (released 2005/11/08)http://www.freetextbox.com/downloads.aspx2. 安裝FreeTextBox 3.0以上版本均支持內部模式,即圖片資源和javascript都集成在dll中,本文僅探討內部模式(Internal Resources).1) 把FTBv3-1-1/Framework-1.1/FreetextBox.dll拷入bin目錄.2) 在項目中添加FreetextBox.dll的dll引用3) Web.config加入如下代碼<?xml version="1.0" encoding="utf-8" ?><configuration> <httpHandlers> <add verb="GET" path="FtbWebResource.axd" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" /></httpHandlers></system.web></configuration>3. 使用FreeTextBox1) aspx頁面頂上 <%@ Register Tag private void FreeTextBox1_SaveClick(object sender, System.EventArgs e){ divshow.InnerHtml = FreeTextBox1.Text;}5) 從客戶端中檢測到有潛在危險的 Request.Form 值<%@ Page language="c#" ... ValidateRequest="false"%>4 圖片上傳1) 工具欄上添加ImageGallery按鈕.<FTB:FreeTextBox ..ToolbarLayout=" ..,InsertImageFromGallery,.. />2) 拷貝 "ftb.imagegallery.aspx" 文件到同一目錄下http://wiki.freetextbox.com/default.aspx/FreeTextBoxWiki.ImageGallery3) FreeTextBox 屬性設置ImageGalleryPath = "~/image/upload" 上傳默認路徑ImageGalleryUrl = "ftb.imagegallery.aspx?rif={0}&cif={0}" ftb.imagegallery.aspx的目錄, 只能用相對目錄,不可以用"~"4) ImageGallery 的設置ftb.imagegallery.aspx文件里<FTB:ImageGallery id="ImageGallery1" JavascriptLocation="InternalResource" UtilityImagesLocation="InternalResource" SupportFolder="~/aspnet_client/FreeTextBox/" AllowImageDelete=true AllowImageUpload=true AllowDirectoryCreate=false AllowDirectoryDelete=falserunat="Server" />AllowDirectoryCreate - 能否建立文件夾AllowDirectoryDelete - 能否刪除文件夾AllowImageUpload - 能否上傳圖片AllowImageDelete - 能否刪除圖片AcceptedFileTypes - 可以上傳文件擴展名的數組(array)為開發者提供的2個屬性CurrentDirectories - a string[] array of directories to allow the user to navigate towardCurrentImages - a FileInfo[] array of files the user should be able to insert. 建議: 刪掉Page_Load事件可以顯著回避上傳圖片不能即時顯示的問題. 不要重寫Page_Load補充========================================================================Freetextbox是一個免費的.net mshtml 編輯器。我所用的免費的freetextbox版本是中文版本1.6.3的漢化的freetextbox。獲得的地址。http://www.percyboy.com/w/ftb/下載之后仔細看看其中的說明,你就可以使用這個完美的編輯器。其中示例是在內聯代碼方式下,如果在代碼后置下使用Freetextbox 呢。1、首先我們把 FreeTextBox.dll 文件copy到我們的項目中的bin目錄里。然后在我們的項目里添加新的引用,在添加引用對話框選擇項目標簽,瀏覽/選擇你的FreeTextBox.dll/打開/確定。應用就添加完成了。2、如何獲得FreeTextBox.dll 中所使用到的名字空間,本中文版本1.6.3 有3個名字空間。using FreeTextBoxControls;using FreeTextBoxControls.Design;using FreeTextBoxControls.Common;可以在引用的FreeTextBox.dll 查看對象瀏覽。點開樹型目錄就可以清晰的看到,上面所說的名字空間了。其他的版本類似可以獲得。3、在aspx文件添加freetextbox<%@ Register TagPrefix="ftb" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>具體的方法和內聯一樣的。同時cs文件中會有如下代碼:protected FreeTextBoxControls.FreeTextBox FreeTextBox1;產生添加完后,運行一下就可以看到結果了。在設計模式下我們還可以查看FreeTextBox 屬性。4、如何把FreeTextBox 內容寫到數據庫,我們在aspx文件中添加一個bottom其的onclick=“my_add"cs文件protected void my_add(object sender, System.EventArgs e) { // 在此處放置用戶代碼以初始化頁面 Response.Write(FreeTextBox1.Text); }此處是輸出內容,可以改成我們需要方法。 FreeTextBox使用方法集合作者:劉一 時間:2005-6-16我在此網站http://www.percyboy.com/w/ftb/down/下載了FreeTextBox 1.6.3 中文版 [307KB]FreeTextBox 1.6.3 中文版源代碼 [420KB]1.先把freetextbox.dll添加到項目中 2.把 - ftb.colorpicker.aspx - ftb.imagegallery.aspx - ftb.inserttable.aspx從文件夾HelperScripts復制出來,放到外面與 - test.aspx (測試)同等級目錄,(不這么做,插入背景色,圖片,表格就不好使) 3.把images文件夾放到test.aspx (測試)同等級目錄下,來存放上傳的圖片. 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"/> -----------------------------------------------------------------------------------------------------這里還有3.0的版本,不過是外文的喲! The no.1 free ASP.NET HTML Editor for IE and Mozilla. FreeTextBox 3.0FreeTextBox 3.0, with over 150,000 downloads, is the most popular cross-browser HTML editor for ASP.NET. To start using the control, do the following Download FreeTextBox 3.0.4Read FreeTextBox Wiki for installation instructionsReport problems to the forumsPurchase a Pro license ($49) or source code/distribution license ($199).Current Version (3.0.4) Information ---------另外補上一文章-------------------------Freetextbox是一個免費的.net mshtml 編輯器。我所用的免費的freetextbox版本是中文版本1.6.3的漢化的freetextbox。獲得的地址。http://www.percyboy.com/w/ftb/下載之后仔細看看其中的說明,你就可以使用這個完美的編輯器。其中示例是在內聯代碼方式下,如果在代碼后置下使用Freetextbox 呢。1、首先我們把 FreeTextBox.dll 文件copy到我們的項目中的bin目錄里。然后在我們的項目里添加新的引用,在添加引用對話框選擇項目標簽,瀏覽/選擇你的FreeTextBox.dll/打開/確定。應用就添加完成了。 2、如何獲得FreeTextBox.dll 中所使用到的名字空間,本中文版本1.6.3 有3個名字空間。using FreeTextBoxControls;using FreeTextBoxControls.Design;using FreeTextBoxControls.Common;可以在引用的FreeTextBox.dll 查看對象瀏覽。點開樹型目錄就可以清晰的看到,上面所說的名字空間了。其他的版本類似可以獲得。3、在aspx文件添加freetextbox<%@ Register TagPrefix="ftb" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>具體的方法和內聯一樣的。同時cs文件中會有如下代碼:protected FreeTextBoxControls.FreeTextBox FreeTextBox1;產生添加完后,運行一下就可以看到結果了。在設計模式下我們還可以查看FreeTextBox 屬性。4、如何把FreeTextBox 內容寫到數據庫,我們在aspx文件中添加一個bottom其的onclick=“my_add"cs文件protected void my_add(object sender, System.EventArgs e) { // 在此處放置用戶代碼以初始化頁面 Response.Write(FreeTextBox1.Text); }此處是輸出內容,可以改成我們需要方法。 ----心得-------------------------------------------------------在使用FreeTextBox控件進行文本編輯后,進行保存時需要取編輯內容對應的HTML文本內容。取編輯內容使用my_freetextbox.ViewStateText屬性會比使用my_freetextbox.Text屬性,在后續的字符串內容處理上會方便一些。在所取出的字符串中,系統自動加上了“/r/n”的回車換行字符串標示,在存儲內容到數據庫之前最好將這些“/r/n”字符串用空串“”替換掉(如:my_str=my_str.Replace("/r/n","")),否則在將來調用時會導致不正常顯示。在所取出的字符串中,系統還把編輯文本中的雙引號“用轉義字符/進行了處理,如原字符串為“wangshixin said "hello!"”,所取得的字符串實際為“wangshixin said /"hello!/"”,因此需要將所獲得的字符串中的全部“/"”用特定的字符串替換掉。在將來提取顯示時,再將特定字符串替換為“/"”(如:my_str=my_str.Replace("/"","wangshixin750920"))。-----還有,再加上--------------------------------------------------------------------------FreeTextBox1.Text 取得內容(帶html標簽的)FreeTextBox1.HtmlStrippedText 也是取得內容(不帶Html標簽的)------關于Word中過來的內容,出錯解決------------------------------------------------------------把從word復制的文本粘貼到freetextbox里,提交到數據庫的時候會提示有危險代碼,也就是單引號,這是為什么?在Dottext里的freetextbox,同一篇word文檔,提交時就沒有問題。我現在找到的原因是dottext里的freetextbox在提交的時候會把危險代碼重新編碼好像,而在我的項目里的freetextbox就不會。查看包含freetextbox控件的頁面源文件,又發現license不同,是不是有 把頁面中的validateRequest指令設成false即可,或者直接改web.config:<pages validateRequest="false" buffer="true"/>
新聞熱點
疑難解答