History
| Custom ToolbarButtons and ToolbarDropDownListsToolbarButtons and ToolbarDropDownLists can be added to a FreeTextBox either programmatically, procedurally, or by inheriting from ToolbarButton or ToolbarDropDownList. Procedurally Creating a ToolbarButtonTo define a custom ToolbarButtons, you must set the Title and ButtonImage properties as well as the ScriptBlock property. To access the FreeTextBox in which the button resides, use the syntax "this.ftb.MethodName" <html> <body> <form runat="server"> <FTB:FreeTextBox id="FreeTextBox1" AutoGenerateToolbarsFromString="false" runat="server" > <Toolbars> <FTB:Toolbar runat="server"> <FTB:ToolbarButton Title="Insert Some Text" ScriptBlock="this.ftb.InsertHtml(ftbName,'FreeTextBox is great!!');" ButtonImage="mybuttonimage" runat="server" /> </Toolbars> </FTB:FreeTextBox> </form> </body> </html> Notes:
In Page_Load CodeInside your Page_Load function, you can add ToolbarButtons to a FreeTextBox control's Toolbars collection property. <script runat="server"> protected void Page_Load(object sender, EventArgs e) { Toolbar toolbar1 = new Toolbar(); ToolbarButton myButton = new ToolbarButton("Insert Some Text","mybuttonimage"); myButton.ScriptBlock = @"this.ftb.InserHtml(""FreeTextBox is great!!"");"; toolbar1.Items.Add(myButton); FreeTextBox1.Toolbars.Add(toolbar1); } </script> <html> <body> <form runat="server"> <FTB:FreeTextBox id="FreeTextBox1" AutoGenerateToolbarsFromString="false" runat="server" /> </form> </body> </html> InheritanceYou can inherit from ToolbarButton to create your own reusable buttons throughout your applications. using System; using FreeTextBoxControls; namespace MyNamespace { public class InsertSomeText : ToolbarButton { public InsertSomeText() : base("Insert Some Text","mybuttonimage") { ScriptBlock = @"this.ftb.InserHtml(""FreeTextBox is great!!"");"; } } } Compile this code into MyNamespace.dll. Then add the control to your ASPX page. <%@ Page ValidateRequest=false %> <%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %> <%@ Register TagPrefix="MY" Namespace="MyNamespace" Assembly="MyNamespace" %> <html> <body> <form runat="server"> <FTB:FreeTextBox id="FreeTextBox1" AutoGenerateToolbarsFromString="false" runat="server" > <Toolbars> <FTB:Toolbar runat="server"> <MY:InsertSomeText runat="server" /> </FTB:Toolbar> </Toolbars> </FTB:FreeTextBox> </form> </body> </html> | Welcome to FreeTextBoxWiki
If you're new to FreeTextBox, read the Installation. | ||||||||||||||||||||||||||||||