天天看点

FreeTextBox 使用详解

1.下载 FreeTextBox

http://freetextbox.com/download/

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加入如下代码

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<system.web>

<httpHandlers>

<add verb="GET" path="FtbWebResource.axd" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox"/>

</httpHandlers>

<system.web>

<configuration>

3. 使用FreeTextBox

1) aspx页面顶上

<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox"%>

2) 调用

<FTB:FreeTextBox ID="FreeTextBox1" runat="Server" ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,FontBackColorsMenu,SymbolsMenu|InsertRule,InsertDate,InsertTime,InsertImageFromGallery,InsertTable|SelectAll,Cut,Copy,Find,Paste,Delete;Undo,Redo,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent|Bold,Italic,Underline,Strikethrough,Superscript,Subscript;CreateLink,Unlink"

            Width="700" Language="zh-CN" ToolbarStyleConfiguration="Office2003" ToolbarBackgroundImage="true"

            ImageGalleryPath="~/image/upload" ImageGalleryUrl="ftb.imagegallery.aspx?rif={0}&cif={0}"

            StartMode="DesignMode">

3)工具栏皮肤

ToolbarStyleConfiguration = Offoce2003/OfficeXP/Office2000/MAC

4) 客户端中检测到有潜在危险的 Request.Form 值

<%@ Page language="c#"

FreeTextBox 使用详解

ValidateRequest="false"%>

4 图片上传

1) 工具栏上添加ImageGallery按钮.

<FTB:FreeTextBox ..ToolbarLayout=" ..,InsertImageFromGallery,.. />

2) 拷贝 "ftb.imagegallery.aspx" 文件到同一目录下,即和你当前页面在同一目录。

3) FreeTextBox 属性设置

Language="zh-CN"  中文

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

继续阅读