版本: 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加入如下代码
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<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" />
3)工具栏皮肤
ToolbarStyleConfiguration = Offoce2003/OfficeXP/Office2000/MAC
4) 得到保存编辑的内容
private void InitializeComponent()
{
this.FreeTextBox1.SaveClick += new System.EventHandler(this.FreeTextBox1_SaveClick);
this.Button1.Click += new System.EventHandler(this.FreeTextBox1_SaveClick);
this.Load += new System.EventHandler(this.Page_Load);
}
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.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
补充
========================================================================
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
其的οnclick=“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添加到项目中 3.把images文件夹放到test.aspx (测试)同等级目录下,来存放上传的图片. 4.在test.aspx 中,加图片的路径 this.FreeTextBox1.Text 这个就是FTB中你输入的文本的内容,这是带HTML标记的 this.FreeTextBox1.HtmlStrippedText 这个是将HTML标记去掉的文本 5.写入数据库
[注]web.config ----------------------------------------------------------------------------------------------------- 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
Current Version (3.0.4) Information ---------另外补上一文章-------------------------
Freetextbox是一个免费的.net mshtml 编辑器。 ----心得------------------------------------------------------- 在使用FreeTextBox控件进行文本编辑后,进行保存时需要取编辑内容对应的HTML文本内容。取编 -----还有,再加上-------------------------------------------------------------------------- FreeTextBox1.Text 取得内容(带html标签的) FreeTextBox1.HtmlStrippedText 也是取得内容(不带Html标签的) 把页面中的validateRequest指令设成false即可,或者直接改web.config:<pages validateRequest="false" buffer="true"/> FreeTextBox 3.0The no.1 free ASP.NET HTML Editor for IE and Mozilla. |