Show Changes Show Changes
Edit Edit
Print Print
Recent Changes Recent Changes
Subscriptions Subscriptions
Lost and Found Lost and Found
Find References Find References
Rename Rename
Search

History

6/3/2016 10:54:18 PM
65.74.128.52
6/6/2007 3:50:45 PM
63.116.110.210
9/17/2006 4:41:59 PM
207.173.198.69
8/17/2005 3:58:43 AM
212.52.196.10
10/4/2005 10:53:08 AM
165.21.154.109
List all versions List all versions
Custom Toolbar Items
.
Summary How to create custom toolbar items

Custom ToolbarButtons and ToolbarDropDownLists

ToolbarButtons and ToolbarDropDownLists can be added to a FreeTextBox either programmatically, procedurally, or by inheriting from ToolbarButton or ToolbarDropDownList.

Procedurally Creating a ToolbarButton

To 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 Code

Inside 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>

Inheritance

You 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.