FreeTextBox使用详解(FTBv3-1-6)

文本编辑框,类似于csdn使用的fckedit。具有广泛的用途。下面介绍其中之一FreeTextBox:

下载FreeTextBox:

http://freetextbox.com/files/6949/download.aspx

下载完解压。

我使用的是Framework-2.0中的FreeTextBox.dll。这个比1.0的要容易上手点,不需要配置太多。

将这个文件夹复制到项目文件的bin目录下。然后添加引用

同时可以复制aspnet_client文件夹及内容进入你的项目文件夹中。我是直接放在根目录下的。这个的用处就是传输图形图像的使用。可以创建,删除文件夹和文件的。没有这个,你使用图像麻烦。

此时你可以参考它自带的英文说明(readme.txt):照做即可。

1 Installation of dll

2 Installing the FreeTextBox support files

上面2步,参考上面的讲解。

3 Using FreeTextBox

将下面的内容加入aspx文件的顶部:

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

加入下面的代码在<form runat="server"> 之间:

   <FTB:FreeTextBox id="FreeTextBox1" runat="Server" />

我的使用如下:

<FTB:FreeTextBox id="FreeTextBox1" runat="Server" AllowHtmlMode="True" ButtonFileExtention="gif,jpg" ImageGalleryPath="~/imagesLib/" ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertImageFromGallery,InsertRule|Cut,Copy,Paste;Undo,Redo,Print" />

这个可以自定义的。readme里也有说明。

 ParagraphMenu, FontFacesMenu, FontSizesMenu, FontForeColorsMenu,
 FontForeColorPicker, FontBackColorsMenu, FontBackColorPicker, Bold, Italic, Underline,
 Strikethrough, Superscript, Subscript, InsertImageFromGallery, CreateLink, Unlink,
 RemoveFormat, JustifyLeft, JustifyRight, JustifyCenter, JustifyFull, BulletedList,
 NumberedList, Indent, Outdent, Cut, Copy, Paste, Delete, Undo, Redo, Print, Save,
 ieSpellCheck, StyleMenu, SymbolsMenu, InsertHtmlMenu, InsertRule, InsertDate,
 InsertTime, WordClean, InsertImage, InsertTable, EditTable, InsertTableRowBefore,
 InsertTableRowAfter, DeleteTableRow, InsertTableColumnBefore, InsertTableColumnAfter,
 DeleteTableColumn, InsertForm, InsertForm, InsertTextBox, InsertTextArea,
 InsertRadioButton, InsertCheckBox, InsertDropDownList, InsertButton, InsertDiv,
 InsertImageFromGallery, Preview, SelectAll, EditStyle

其中的参数添加在ToolbarLayout中。比较有用的红色显示。

这样你可以运行了。

界面如下:

class="FreeTextBox1_DesignBox" id="FreeTextBox1_designEditor" style="padding: 0px; width: 598px; height: 349px;" src="about:blank">
   Design  HTML
 

如果出现如下错误:A potentially dangerous Request.Form value was detected from the client

则需要添加代码:ValidateRequest="false"

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FreeTextBox.aspx.cs" Inherits="FreeTextBox" ValidateRequest="false" %>

注意:你可以在属性窗口中进行众多设置。自己体会一下。

比如:ImageGalleryPath设置为~/imagesLib/

 下面讲解图像处理:

复制ftb.imagegallery.aspx进入项目文件夹:

<FTB:ImageGallery id="ImageGallery1"
   JavaScriptLocation="ExternalFile"
   UtilityImagesLocation="ExternalFile"
   SupportFolder="~/aspnet_client/FreeTextBox/"
   AllowImageDelete="true" AllowImageUpload="true" AllowDirectoryCreate="true" AllowDirectoryDelete="true"  runat="Server" />

我的代码如下:

<% @ Page Language = " C# "  ValidateRequest = " false "  Trace = " false "   %>
<% @ Register TagPrefix = " FTB "  Namespace = " FreeTextBoxControls "  Assembly = " FreeTextBox "   %>
< script runat = " server " >
protected   void  Page_Load(Object Src, EventArgs E)  {
    
    
// *** remove this return statement to use the following code ***
    return;

    
string currentFolder = ImageGallery1.CurrentImagesFolder;
    
    
// modify the directories allowed
    if (currentFolder == "~/imagesLib"{

        
// these are the default directories FTB:ImageGallery will find
        string[] defaultDirectories = System.IO.Directory.GetDirectories(Server.MapPath(currentFolder),"*");
        
        
// user defined custom directories
        string[] customDirectories = new string[] {"folder1","folder2"};
        
        
// the gallery will use these images in this instance
        ImageGallery1.CurrentDirectories = customDirectories;
    }

    
    
    
// modify the images allowed
    if (currentFolder == "~/imagesLib"{

        System.IO.DirectoryInfo directoryInfo 
= new System.IO.DirectoryInfo(Server.MapPath(currentFolder));

        
// these are the default images FTB:ImageGallery will find
        System.IO.FileInfo[] defaultImages = directoryInfo.GetFiles("*");
        
        
// user defined custom images (here, we're just allowing the first two)
        System.IO.FileInfo[] customImages = new System.IO.FileInfo[2{defaultImages[0], defaultImages[1]};
        
        
// the gallery will use these images in this instance
        ImageGallery1.CurrentImages = customImages;
    }
    
    
}

</ script >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head >
    
< title > Image Gallery </ title >
</ head >
< body >

    
< form id = " Form1 "  runat = " server "  enctype = " multipart/form-data " >   
    
        
< FTB:ImageGallery id = " ImageGallery1 "  
            JavaScriptLocation
= " ExternalFile "  
            UtilityImagesLocation
= " ExternalFile "  
            SupportFolder
= " ~/aspnet_client/FreeTextBox/ "
            AllowImageDelete
= " true "  AllowImageUpload = " true "  AllowDirectoryCreate = " true "  AllowDirectoryDelete = " true "   runat = " Server "   />
        
    
</ form >

</ body >
</ html >

 

自己对应文件夹体会一下:

SupportFolder="~/aspnet_client/FreeTextBox/" 就是对应的你复制的aspnet_client文件夹。

currentFolder == "~/imagesLib" 就是你设定的图像存储文件夹。运行后你可以新建或删除文件夹。

AllowImageDelete="true" AllowImageUpload="true" AllowDirectoryCreate="true" AllowDirectoryDelete="true"

就是使得上述功能能够使用。

我将其<htm>修改为<html xmlns="http://www.w3.org/1999/xhtml">省得老是报错。

默认的语言设置为英文,改为中文的用对应的那个值Language="zh-CN"。

测试通过。

下面贴一个我师兄用的布局图:<FTB:FreeTextBox id="FreeTextBoxXinXiNeiRong" runat="Server" AllowHtmlMode="True" ButtonFileExtention="gif,jpg,*.*" ImageGalleryPath="~/imagesLib/" ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertRule,InsertImageFromGallery|Cut,Copy,Paste;Undo,Redo,Print" Height="400px" Width="550px" Language="zh-CN" />


我的添加了个表格
ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertRule,InsertImageFromGallery,InsertTable|Cut,Copy,Paste;Undo,Redo,Print
FreeTextBox3.2.2简体中文版示例源码 FreeTextBox是一款免费的Asp.net网页编辑器,官方默认为英文版,该版本设置为简体中文版,可以设置文字样式、在线排版、图片上传等(FreeTextBox源码需要单独购买授权),该代码包括了各类应用的演示和实现过程 包括:功能设置、下拉显示、多语言(包括简体中文、繁体、英文等)切换、JS调用、WebParts应用、Ajax无刷新交互、 直接使用的方法: (1) 复制 bin 目录下的 FreeTextBox.dll 文件到你的 Web 应用程序目录中的 bin 目录; (2) 复制 HelperScripts 目录下的三个文件到你的 Web 应用程序目录中或其子目录中,注意使用时要指定 HelperFilePath 属性; 假设把三个文件放于应用程序下的 helpfile 目录:this.FreeTextBox1.HelperFilesPath="helpfile"; 即指向了此目录。 (3) 复制 images 目录下的 ftb 目录到你的 Web 站点根目录下的 images 目录中。 此目录中包含界面的各种皮肤图片 (4) 在应用程序目录下建立images目录,此目录用于上传图片的图片库,必须有,否则插入图片将不可用 (5) 使用:在应用程序中建立相应的WEB窗体 在HTML代码页 页头添加<%@ Register TagPrefix="ftb" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %> 引入控件标签 复制<FTB:FreeTextBox id="FreeTextBox1" runat="server" Width="500px" Height="400px" />到页面中需要的位置 也可以把控件添加到工具栏,通过直接拖拽来使用控件 文件夹下有Asp.net1.1/2.0/3.5各个环境下可以使用FreeTextBox.dll
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值