FreeTextBox使用詳解
FreeTextBox使用詳解
Author: Annerose Date:12/16/2005
版本: FreeTextBox 3.1.1 ASP.NET1.1
1.下載 FreeTextBox 3.1.1 (released 2005/11/08)
http://www.freetextbox.com/downloads.aspx
2. 安裝
FreeTextBox 3.0以上版本均支持內部模式,即圖片資源和javascript都集成在dll中, 本文僅探討內部模式(Internal Resources).
1) 把FTBv3-1-1/Framework-1.1/FreetextBox.dll拷入bin目錄.
2) 在項目中添加FreetextBox.dll的dll引用
3) Web.config加入如下代碼3. 使用FreeTextBox
1<?xmlversion="1.0"encoding="utf-8"?>
2<configuration>
3<system.web>
4<httpHandlers>
5<addverb="GET"path="FtbWebResource.axd"type="FreeTextBoxControls.AssemblyResourceHandler,FreeTextBox"/>
6</< span>httpHandlers>
7<system.web>
8<configuration>
1) aspx頁面頂上
2) 調用3)工具欄皮膚
4) 得到保存編輯的內容
5) 客戶端中檢測到有潛在危險的 Request.Form 值4 圖片上傳
1) 工具欄上添加ImageGallery按鈕.
2) 拷貝 "ftb.imagegallery.aspx" 文件到同一目錄下
http://wiki.freetextbox.com/default.aspx/FreeTextBoxWiki.ImageGallery
<FTB:FreeTextBoxid="FreeTextBox1"runat="Server"/>
ToolbarStyleConfiguration=Offoce2003/OfficeXP/Office2000/MAC
1privatevoidInitializeComponent()
2{
3//指向同一個委託
4this.FreeTextBox1.SaveClick+=newSystem.EventHandlerthis.FreeTextBox1_SaveClick);
5this.Button1.Click+=newSystem.EventHandler(this.FreeTextBox1_SaveClick);
6}
7
8privatevoidFreeTextBox1_SaveClick(objectsender,System.EventArgse)
9{
10divshow.InnerHtml=FreeTextBox1.Text;
11}
<FTB:FreeTextBox..ToolbarLayout="..,InsertImageFromGallery,../>
3) FreeTextBox 屬性設置
ImageGalleryPath = "~/image/upload" 上傳默認路徑
ImageGalleryUrl = "ftb.imagegallery.aspx?rif={0}&cif={0}" ftb.imagegallery.aspx的目錄, 只能用相對目錄,不可以用"~"
4) ImageGallery 的設置
ftb.imagegallery.aspx文件裏
AllowDirectoryCreate - 能否建立文件夾
AllowDirectoryDelete - 能否刪除文件夾
AllowImageUpload - 能否上傳圖片
AllowImageDelete - 能否刪除圖片
AcceptedFileTypes - 可以上傳文件擴展名的數組(array)
<FTB:ImageGalleryid="ImageGallery1"
JavaScriptLocation="InternalResource"UtilityImagesLocation="InternalResource"
SupportFolder="~/aspnet_client/FreeTextBox/"
AllowImageDelete=true
AllowImageUpload=true
AllowDirectoryCreate=false
AllowDirectoryDelete=false
runat="Server"/>
爲開發者提供的2個屬性
CurrentDirectories - a string[] array of directories to allow the user to navigate toward
CurrentImages - a FileInfo[] array of files the user should be able to insert.
建議: 刪掉Page_Load事件可以顯著迴避上傳圖片不能即時顯示的問題. 不要重寫Page_Load
That's all. Thanks
Annerose
12/26/2005
=======================
By the way.My first post:
http://blog.hexun.com/annerose/1779631/viewarticle.html
.先把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"/>
上面的是我自己的使用方法,不一定是很好的.如果你發現更好的方法,別忘了告訴我呀!
ftb.imagegallery.aspx文件
private string NoFileMessage = "您沒有選擇文件。";
private string UploadSuccessMessage = "上傳成功";
private string UploadFailureMessage = "上傳失敗。";
private string NoImagesMessage = "該文件夾不存在或者是空的";
private string NoFolderSpecifiedMessage = "您要上傳到的文件夾不存在。";
private string NoFileToDeleteMessage = "您沒有選中要刪除的文件。";
private string InvalidFileTypeMessage = "您無法上傳這種類型的文件。";
private string[] AcceptedFileTypes = new string[] {"jpg","jpeg","jpe","gif","png","rar"};
// Configuration
private bool UploadIsEnabled = true; // 是否允許上傳文件
private bool DeleteIsEnabled = false; // 是否允許刪除文件
private string DefaultImageFolder = "images"; // 默認的起始文件夾