http://astate.cnblogs.com/archive/2005/12/16/annerose.html
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加入如下代碼
1<?xml version="1.0" encoding="utf-8" ?>
2 <configuration>
3 <system.web>
4 <httpHandlers>
5 <add verb="GET" path="FtbWebResource.axd" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" />
6 </httpHandlers>
7 <system.web>
8 <configuration>
3. 使用FreeTextBox
1) aspx頁面頂上
<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
2) 調用
<FTB:FreeTextBox id="FreeTextBox1" runat="Server" />
3)工具列皮膚
ToolbarStyleConfiguration = Offoce2003/OfficeXP/Office2000/MAC
4) 得到儲存編輯的內容
1 private void InitializeComponent()
2 {
3 // 指向同一個委託
4 this.FreeTextBox1.SaveClick += new System.EventHandler this.FreeTextBox1_SaveClick);
5 this.Button1.Click += new System.EventHandler(this.FreeTextBox1_SaveClick);
6 }
7
8 private void FreeTextBox1_SaveClick(object sender, System.EventArgs e)
9 {
10 divshow.InnerHtml = FreeTextBox1.Text;
11 }
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.ImageGallery
3) 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=false
runat="Server" />
AllowDirectoryCreate - 能否建立檔案夾
AllowDirectoryDelete - 能否刪除檔案夾
AllowImageUpload - 能否上傳圖片
AllowImageDelete - 能否刪除圖片
AcceptedFileTypes - 可以上傳副檔名的數組(array)
為開發人員提供的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