UQYT

FreeTextBox使用说明

1.如何在客户端用JS获取及设置FreeTextBox的内容?

FreeTextBox使用说明 - shunhe316 - 我的博客   function getFtb()
FreeTextBox使用说明 - shunhe316 - 我的博客   
{
FreeTextBox使用说明 - shunhe316 - 我的博客       
var html = FTB_API["FreeTextBox1"].GetHtml();
FreeTextBox使用说明 - shunhe316 - 我的博客        alert(html);
FreeTextBox使用说明 - shunhe316 - 我的博客    }

FreeTextBox使用说明 - shunhe316 - 我的博客
//上面是获取FreeTextBox里的值
FreeTextBox使用说明 - shunhe316 - 我的博客//
下面是对 FreeTextBox进行赋值操作
FreeTextBox使用说明 - shunhe316 - 我的博客
   function setFtb()
FreeTextBox使用说明 - shunhe316 - 我的博客   
{
FreeTextBox使用说明 - shunhe316 - 我的博客        
var temp = document.getElementById("Text1").value ;
FreeTextBox使用说明 - shunhe316 - 我的博客         FTB_API[
"FreeTextBox1"].SetHtml(temp);
FreeTextBox使用说明 - shunhe316 - 我的博客    }

 

2.如何把FreeTextBox的所有工具按钮显示出来
设置它的ToolbarLayout属性

ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,
FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat,Insert Date,Insert Time,SelectAll,Preview|JustifyLeft,JustifyRight,JustifyCenter,
JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,
InsertImage,InsertRule,InsertImageFromGallery|Cut,Copy,Paste;Undo,Redo,Print"

至于里面的值如何得到可以参考它官方网站上介绍的特性FreeTextBox 3.0 Features
http://freetextbox.com/features/
直接复制左边的英文介绍
当然如果你是免费用户,是不可能看到全部工具按钮的

3.客户端调用ftb的API函数

FTB_API[\'ctl00_bcr_FreeTextBox1\'].ExecuteCommand(\'bold\');
使字体变为粗体

FTB_API[\'ctl00_bcr_FreeTextBox1\'].ExecuteCommand(\'italic\');
使字体变为斜体

FTB_API[\'ctl00_bcr_FreeTextBox1\'].ExecuteCommand(\'createlink\',null,document.getElementById(\'LinkUrl\').value);"
为文字添加连接

问题1:我想实现自动保存功能,所以想捕获ftb的onTextchange事件在客户端,如何捕获
官方论坛上给出如下解决方案,我式了不行

Property:
ClientSideTextChanged
="CharCount"
OR

ClientSideTextChanged
="SetTextBox"

Javascript
function CharCount(ftb)
{
var html = ftb.GetHtml();
var o = document.getElementById(\'charcnt\');
o.value = html.length;
window.status = html.length;
}
function SetTextBox(ftb)
{
var html = ftb.GetHtml();
var o = document.getElementById(\'textwritten\');
o.value = ftb.GetHtml();
}

问题2:我设置好了ImageGalleryPath ,也能弹出ImageGallery,但是默认图片为叉子 ,如何处理


  

FreeTextBox使用说明 - shunhe316 - 我的博客<FTB:FreeTextBox ID="FreeTextBox1" runat="server" ImageGalleryPath="/aspnet_client/FreeTextBox/images/"
FreeTextBox使用说明 - shunhe316 - 我的博客                                     UseToolbarBackGroundImage
="True" ButtonSet="Office2003" ImageGalleryUrl="/aspnet_client/FreeTextBox/ftb.imagegallery.aspx?rif={0}&cif={0}"

FreeTextBox使用说明 - shunhe316 - 我的博客                                     Language
="zh-CN" ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,
FreeTextBox使用说明 - shunhe316 - 我的博客FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat,Insert Date,Insert Time,SelectAll,Preview|JustifyLeft,JustifyRight,JustifyCenter,
FreeTextBox使用说明 - shunhe316 - 我的博客JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,
FreeTextBox使用说明 - shunhe316 - 我的博客InsertRule,InsertImageFromGallery|Cut,Copy,Paste;Undo,Redo,Print"

FreeTextBox使用说明 - shunhe316 - 我的博客                                     Width
="700px">
FreeTextBox使用说明 - shunhe316 - 我的博客                                
</FTB:FreeTextBox>

string str=FreeTextBox1.Text
这样写的,如果Text中有空格
那保存后,显示就是 ?
这是为啥了?

后来把数据库中的这个空格copy出来,转化成ASCII码是:160

原来,utf-8格式只对127以内的ASCII码是直接处理,所以需要进行处理下:

FreeTextBox使用说明 - shunhe316 - 我的博客Str.Replace(System.Web.HttpUtility.HtmlDecode("&nbsp;"), "&nbsp;");


这样的话就没有问题了!

希望给遇到这个问题的同胞们一点帮助!

分类:

技术点:

相关文章: