续 Freetextbox1.63中文版的使用(二)

前面写过Freetextbox1.63的基本使用,

现在基于boss的特殊要求,上传附件.相关附件主要为doc,或者war格式.

首先,找到freetextbox源码,在ToolbarItems类里面添加静态属性如下:

  ///

/// Returns a ToolbarButton with InsertFileFromGallery JavaScript functions builtin /// public static ToolbarButton InsertFileFromGallery { get { ToolbarButton button = new ToolbarButton("插入附件(来自文件库)","insertfilefromgallery","FTB_InsertFileFromGallery_CLIENTID"); button.ScriptBlock = @""; return button; } }

 

第二步,在ToolbarGenerator 类里面,添加相关上传控件的识别代码public static string DefaultConfigString = "Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|FontFacesMenu,FontSizesMenu,FontForeColorsMenu|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImageFromGallery,InsertFileFromGallery,InsertTable,InsertRule|Cut,Copy,Paste;Undo,Redo,Print,ieSpellCheck"; public static string AlternateConfigString = "Save,Print,Undo,Redo,WordClean,InsertTable|ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorPicker,FontBackColorPicker,SymbolsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImageFromGallery,InsertFileFromGallery,InsertRule|Cut,Copy,Paste,ieSpellCheck"; public static string EnableAllConfigString = "ParagraphMenu,FontFacesMenu,FontSizesMenu|FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu,FontBackColorPicker|Bold,Italic,Underline,Strikethrough,Superscript,Subscript;InsertImageFromGallery,InsertFileFromGallery,CreateLink,Unlink,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent|Cut,Copy,Paste,Delete;Undo,Redo,Print,Save|StyleMenu,SymbolsMenu,InsertHtmlMenu|InsertRule,InsertDate,InsertTime,WordCount,ieSpellCheck,WordClean,InsertTable";

 

为方法,添加识别

public static ToolbarItem ToolbarItemFromString(string StringName) { switch (StringName.ToLower()) { case "insertfilefromgallery": return ToolbarItems.InsertFileFromGallery; }}

 

 

 第三步.在FreeTextBox类里,

更改方法ProcessToolbarButton(ToolbarButton myButton)  public virtual void ProcessToolbarButton(ToolbarButton myButton) { myButton.Function = myButton.Function.Replace("CLIENTID",this.ID); myButton.ScriptBlock = myButton.ScriptBlock.Replace("CLIENTID",this.ID); myButton.ScriptBlock = Regex.Replace(myButton.ScriptBlock,"(?[^<]+)",Page.GetPostBackEventReference(this,"${command}")); switch (myButton.Name.ToLower()) { case "insertimagefromgallery": myButton.ScriptBlock = myButton.ScriptBlock.Replace("IMAGEGALLERYPATH",this.ImageGalleryPath); break; case "insertfilefromgallery": myButton.ScriptBlock = myButton.ScriptBlock.Replace("FILEGALLERYPATH",this.FileGalleryPath); break; default: break; } }

 

添加属性

 

///

/// The path to for the InsertImageFromGallery Button. Defaults to "File". Use forward slashes "/" and do not all leading or trailing slashes. /// [ CategoryAttribute("外部的"), DescriptionAttribute("获取或设置File地址。默认为“File”。不要以“/”开头或结尾,相对于应用程序起始目录。") ] public string FileGalleryPath { get { object savedState = this.ViewState["FileGalleryPath"]; return (savedState == null) ? "images" : (string) savedState; } set { value.Replace("//","/"); if (value.Substring(0,1) == "/") value = value.Substring(1,value.Length-1); if (value.Substring(value.Length-1,1) == "/") value = value.Substring(0,value.Length-1); ViewState["FileGalleryPath"] = value; } }

 

第四步.. 貌似忘了点啥.想不起来了. ....

 

 

第五步. 使用的项目前台增加ftb.filegallery.aspx文件, 用来上传与选取附件.

页面主要代码与ftb.imagegallery.aspx 基本一致,在显示方式有所不同,

比如获取不同类型文件,显示该文件类型的gif.

保存方式与image 一直,在前台生成files文件夹, 根据登陆人id创建个人专属文件夹.

这里具体要操作的相当琐碎, 就不赘述了.

 

至此,完成boss要求...

 

总结:对freetextbox的核心更加的了解,受益良多...

在研究源码的时候比较费时,而且第五步相当繁琐,需要认真细心.

时间估算有误,下次应该更客观的分析问题与需求.

PS:I hate vs2003... 至少因为它浪费了2个多小时....

 

 

 

你可能感兴趣的:(ASP.NET,学习)