×

freetextbox

freetextbox(FreeTextBox的问题 高手来)

admin admin 发表于2023-02-17 10:13:55 浏览26 评论0

抢沙发发表评论

本文目录

FreeTextBox的问题 高手来

一、使用方法
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();
}
二、注意
1、在web.config中system.web节加入: 《pages validateRequest=“false“/》
否则会出现如下错误:
从客户端(Content=“《FORM language=javas...“)中检测到有潜在危险的 Request.Form 值。
说明: 请求验证过程检测到有潜在危险的客户端输入值,对请求的处理已经中止。该值可能指示危及应用程序安全的尝试,如跨站点的脚本攻击。通过在 Page 指令或 配置节中设置 validateRequest=false 可以禁用请求验证。但是,在这种情况下,强烈建议应用程序显式检查所有输入。
异常详细信息: System.Web.HttpRequestValidationException: 从客户端(Content=“《FORM language=javas...“)中检测到有潜在危险的 Request.Form 值。
2、如果你想对其他页面要进行从客户端(Content=“《FORM language=javas...“)中检测,你就麻烦一点,在调用freetextbox的页面上添加 validateRequest=“false“ ,如:
《%@ Page language=“c#“ validateRequest=“false“ Codebehind=“WebForm1.aspx.cs“ AutoEventWireup=“false“ Inherits=“bizflat.WebForm1“ %》
三、实现机制
刚开始试用FTB2.0的时候,感觉FTB真的很神,居然可以在网页状态实现编辑过程的What you see is what you get。看完FTB的文档(其实也不是很多的东西,估计就是用个NDOC或者什么类似的工具生成的SDK文档)又仔细试做了几个程序,觉得FTB的实现思路不复杂,但十分巧妙。它通过FTB这个中间部件将客户端(浏览器)的程序(javascript代码)和后台程序(C#写的aspx等ASP.NET代码)紧密结合,从而实现了这种所见即所得的效果。
FTB的结构主要有三个命名空间组成:
FreeTextBoxControls,FreeTextBoxControls.Design和FreeTextBoxControls.Support。
使用得最多的是FreeTextBoxControls,基本上用到的界面部件都来自于这里,例如ToolBar上每个功能Button可以在这里找到映射,而每个Button又对应着javascrip中的一个函数功能。
例如:下划线这个功能,有个Underline的类(继承于ToolbarButton)实现,而这个类实际调用客户端的一段javascript代码FTB_Underline(在FreeTextBox-ToolbarItemsSrcipt.js中)。
function FTB_Underline(ftbName) {
FTB_Format(ftbName,’underline’);
如果再深究下去,仔细跟踪下这段js的代码又可以它调用FTB_Format这段代码(在FreeTextBox-MainScript.js中)。
function FTB_Format(ftbName,commandName) {
editor = FTB_GetIFrame(ftbName);
if (FTB_IsHtmlMode(ftbName)) return;
editor.focus();
editor.document.execCommand(commandName,’’,null);
}
它正是通过document的execCommand方法来实现效果的,查MSDN文挡可以发现它对应执行的正是Underline的命令参数。
execCommand可以执行的命令参数:
Command Identifiers
2D-Position
Allows absolutely positioned elements to be moved by dragging.
AbsolutePosition
Sets an element’s position property to “absolute.“
BackColor
Sets or retrieves the background color of the current selection.
BlockDirLTR
Not currently supported.
BlockDirRTL
Not currently supported.
Bold
Toggles the current selection between bold and nonbold.
BrowseMode
Not currently supported.
ClearAuthenticationCache
Clears all authentication credentials from the cache. Applies only to execCommand.
Copy
Copies the current selection to the clipboard.
CreateBookmark
Creates a bookmark anchor or retrieves the name of a bookmark anchor for the current selection or insertion point.
CreateLink
Inserts a hyperlink on the current selection, or displays a dialog box enabling the user to specify a URL to insert as a hyperlink on the current selection.
Cut
Copies the current selection to the clipboard and then deletes it.
Delete
Deletes the current selection.
DirLTR
Not currently supported.
DirRTL
Not currently supported.
EditMode
Not currently supported.
FontName
Sets or retrieves the font for the current selection.
FontSize
Sets or retrieves the font size for the current selection.
ForeColor
Sets or retrieves the foreground (text) color of the current selection.
FormatBlock
Sets the current block format tag.
Indent
Increases the indent of the selected text by one indentation increment.
InlineDirLTR
Not currently supported.
InlineDirRTL
Not currently supported.
InsertButton
Overwrites a button control on the text selection.
InsertFieldset
Overwrites a box on the text selection.
InsertHorizontalRule
Overwrites a horizontal line on the text selection.
InsertIFrame
Overwrites an inline frame on the text selection.
InsertImage
Overwrites an image on the text selection.
InsertInputButton
Overwrites a button control on the text selection.
InsertInputCheckbox
Overwrites a check box control on the text selection.
InsertInputFileUpload
Overwrites a file upload control on the text selection.
InsertInputHidden
Inserts a hidden control on the text selection.
InsertInputImage
Overwrites an image control on the text selection.
InsertInputPassword
Overwrites a password control on the text selection.
InsertInputRadio
Overwrites a radio control on the text selection.
InsertInputReset
Overwrites a reset control on the text selection.
InsertInputSubmit
Overwrites a submit control on the text selection.
InsertInputText
Overwrites a text control on the text selection.
InsertMarquee
Overwrites an empty marquee on the text selection.
InsertOrderedList
Toggles the text selection between an ordered list and a normal format block.
InsertParagraph
Overwrites a line break on the text selection.
InsertSelectDropdown
Overwrites a drop-down selection control on the text selection.
InsertSelectListbox
Overwrites a list box selection control on the text selection.
InsertTextArea
Overwrites a multiline text input control on the text selection.
InsertUnorderedList
Toggles the text selection between an ordered list and a normal format block.
Italic
Toggles the current selection between italic and nonitalic.
JustifyCenter
Centers the format block in which the current selection is located.
JustifyFull
Not currently supported.
JustifyLeft
Left-justifies the format block in which the current selection is located.
JustifyNone
Not currently supported.
JustifyRight
Right-justifies the format block in which the current selection is located.
LiveResize
Causes the MSHTML Editor to update an element’s appearance continuously during a resizing or moving operation, rather than updating only at the completion of the move or resize.
MultipleSelection
Allows for the selection of more than one site selectable element at a time when the user holds down the SHIFT or CTRL keys.
Open
Not currently supported.
Outdent
Decreases by one increment the indentation of the format block in which the current selection is located.
OverWrite
Toggles the text-entry mode between insert and overwrite.
Paste
Overwrites the contents of the clipboard on the current selection.
PlayImage
Not currently supported.
Print
Opens the print dialog box so the user can print the current page.
Redo
Not currently supported.
Refresh
Refreshes the current document.
RemoveFormat
Removes the formatting tags from the current selection.
RemoveParaFormat
Not currently supported.
SaveAs
Saves the current Web page to a file.
SelectAll
Selects the entire document.
SizeToControl
Not currently supported.
SizeToControlHeight
Not currently supported.
SizeToControlWidth
Not currently supported.
Stop
Not currently supported.
StopImage
Not currently supported.
StrikeThrough
Not currently supported.
Subscript
Not currently supported.
Superscript
Not currently supported.
UnBookmark
Removes any bookmark from the current selection.
Underline
Toggles the current selection between underlined and not underlined.
Undo
Not currently supported.
Unlink
Removes any hyperlink from the current selection.
Unselect
Clears the current selection.
基本上每个命令参数都可以在FTB的FreeTextBoxControls中找到对应的实现类,如果觉得有些没有实现,自己参照已经实现的功能来增加也十分简单和方便。
FTB还提供了公开的接口,例如继承于ToolbarButton可以实现对应的工具按钮,继承于ToolbarDropDownList则实现下拉式选择(如选择字体那种),对应javascript的方法只须传递对应的方法名字符串给类即可,自己写的javascript可以放在js中,也可以放在 ScriptBlock的字符串参数里面,前者前端查看源码看不到,后者则将整个函数源码传回,一切都十分公开和方便。
这种思路是否也和ASP.NET的思路类似?
由于javascript可以被多种浏览器支持(估计有些小兼容问题,可以通过javascript来兼容),因此FTB可以在多种环境下正常工作。现在用的这个blog系统(.Text)也用了FTB,但版本是1.6.3.26037(汉化版),有兴趣可以在发表文章的地方查看网页源代码看看,就会发现好多的FTB_XXX的javascript函数。这些在2.0已经全部集中放到FreeTextBox-ToolbarItemsSrcipt.js和 FreeTextBox-MainScript.js中了,应该说这样比较归一些。
如果担心FTB的免费协议对商业用途有些影响的话,自己根据这个思路来开发一个适合自己产品用的所见即所得编辑器控件应该也不是难事。

asp.net 3.5 中的FreeTextBox

freetextbox我用过,很好用。
先在项目-添加应用-浏览,找到freetextbox.dll,并添加
在工具箱里右键-选项卡,找到Freetextbox.dll.添加控件。
这个时候你的工具箱上面就会出现freetextbox控件了,你就像使用文本框一样,一拖就可以了。
有的FreeTextbox控件需要将他的一个文件放在相应的位置,以便实现图片上传。还需要在Freetextbox属性里面设定上传文件的路径。其实一般这些控件的帮助都写的很详细。

Freetextbox 在ASP.NET(C#)中无法显示全部功能

你的freetextbox是什么版本的?
freetextbox的菜单是可以设置的,默认好像是normal方式,不是所有的菜单都显示。
string
fc
=
new
string;
fc
=
“宋体“;
fc
=
“楷体_GB2312“;
fc
=
“隶书“;
fc
=
“黑体“;
fc
=
“仿宋“;
fc
=
“Arial“;
fc
=
“Times
New
Roman“;
this.FreeTextBox1.FontFacesMenuList
=
fc;
//this.FreeTextBox1.AutoConfigure
=
FreeTextBoxControls.AutoConfigure.EnableAll;
//全设置,或者自己设
this.FreeTextBox1.ToolbarLayout
=
“ParagraphMenu,FontFacesMenu,FontSizesMenu,WordClean,InsertTable,InsertImage,Bold,Italic,Underline,StrikeThrough,SubScript,SuperScript,FontForeColorPicker,JustifyLeft,JustifyRight,JustifyCenter|SelectAll,Cut,Copy,Find,Paste,Delete;Undo,Redo,RemoveFormat“;

求FreeTextBox的详细用法,最好有例子

1.直接使用的方法:
(1) 复制 bin 目录下的 FreeTextBox.dll 文件到你的 Web 应用程序目录中的 bin 目录或其上层的虚拟目录下的 bin 目录;
(2) 复制 HelperScripts 目录下的三个文件到你的 Web 应用程序目录中或其子目录中,注意使用时要指定 HelperFilePath 属性;
(3) 复制 images 目录下的 ftb 目录到你的 Web 站点根目录下的 images 目录中。
默认的目录结构如下:
+ Web 根目录
+ bin 目录
- FreeTextBox.dll
+ images 目录
+ ftb 目录
+ 你的应用程序(虚拟目录)
+ bin 目录
- FreeTextBox.dll
+ images 目录(这个是你的“图片库”目录,上传的图片都在此)
- ftb.colorpicker.aspx
- ftb.imagegallery.aspx
- ftb.inserttable.aspx
- test.aspx (测试)
(注:+ 表示目录,- 表示文件;上面 FreeTextBox.dll 只需要复制一个就行了;)
2.或者你可以更改源代码来简化某些设置。
3.官方网站:

freetextbox

在“《%@ page “中设置validateRequest的值为false,不然会提示“请求验证过程检测到有潜在危险的客户端输入值,对请求的处理已经中止。
另外建议看下:
.Net中Freetextbox的使用与ftb.imagegallery.aspx安全修正

未能从程序集 freetextbox 中加载类型 FreeTextBoxControls.FREETEXTBOX

freetextbox是.net环境下使用最多的在线文本编辑器,其强大的功能使它应用在各种项目中.在此我就自己在使用这一控件中的一些心得与大家共享:(我用的是1.6中文版,因为1.6以上不是开源的,好多功能免费的是不能实现的)

用法还是比较简单的:首先我们把 FreeTextBox.dll 文件copy到我们的项目中的bin目录里。
然后在我们的项目里添加新的引用,在添加引用对话框选择项目标签,浏览/选择你的FreeTextBox.dll/打开/确定。应用就添加完成了。

在aspx文件添加freetextbox的方法是:添加代码:《%@ Register TagPrefix=“ftb“ Namespace=“FreeTextBoxControls“ Assembly=“FreeTextBox“ %》
具体的方法和内联一样的。同时cs文件中会有如下代码:protected FreeTextBoxControls.FreeTextBox FreeTextBox1;产生
添加完后,运行一下就可以看到结果了。

在配置文件时我们应将ftb.colorpicker.aspx,ftb.imagegallery.aspx,ftb.inserttable.aspx从从文件夹HelperScripts复制出来,放到外面与与你的.aspx同等级目录(images文件夹也应放到此目录下)
注意:this.FreeTextBox1.Text这个就是FTB中你输入的文本的内容,这是带HTML标记的this.FreeTextBox1.HtmlStrippedText这个是将HTML标记去掉的文本
使用FreeTextBox1.Text就可以了
将其文本存入数据库也就变的简单了,我们只需编写以下代码就可以了:
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();
}
在运行是我们有可能会看到如下错误:检测到有潜在危险的 Request.Form 值这是 ASP.NET 1.1 中新增的防止非法提交的措施.你只要将 *.aspx 头部的《%@ Page language=“c#“ CodeBehind=“ftb.imagegallery.aspx.cs“ AutoEventWireup=“false“ Inherits=“ftb.ftb_imagegallery“ %》
中增添 ValidateRequest=“false“ 的属性说明就行了
问题2就是网上提供大多中文版的在你添加图片时会出现空白页(郁闷,原版就没事)这个问题可参考CSDN上的说明就行了.
当然由于是开源的所以我们可以方便的添加各种功能(如添加插入视频按钮,插入FLASH按钮等,学习中....),这就是开源的好处啊!!!!!

但是从网上来看它的问题也不少(也许是树大招风吧),有人说ASP的在线编辑器eWebEditor也可配置到.net中而且比Freetextbox要好用(有谁知道如何配置啊????).

PS:以上的配置是freetextbox的默认配置,我们也可以更改他的源码来改变他的一些默认路径(这又是开源的个一好处),同时我们还可以任意更改它的外观和功能让它更加适用我们的项目

还有本来想按照其自己写个来着,不过还偶许多技术的东西没有掌握啊(还是改源码比较好啊),看来我学习的路还很长啊.....

FreeTextBox 的问题

如果你要添加到后台的话。
将这个FreeTextBox1.Value值插入到数据库。
要显示的话。
可以把他绑定到LABLE。