Re: how can i add a button to the toolbar programmatically?

  •  10-18-2012, 7:13 AM

    Re: how can i add a button to the toolbar programmatically?

    Hi dubi,

     

    The example page below shows you how to add the custom button to the end of the toolbar.

     

    1. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>  
    2.   
    3. <%@ Page Language="c#" %>  
    4.   
    5. <html>  
    6. <head>  
    7.     <title>example</title>  
    8. </head>  
    9.   
    10. <script runat="server">  
    11.     private void Page_Load(object sender, System.EventArgs e)  
    12.     {  
    13.         //get last button index  
    14.         int pos = Editor1.ToolControls.IndexOf("JustifyRight") + 1;  
    15.         WebControl ctrl = Editor1.CreateCommandButton("MyButton""text.gif""Insert My Custom Text");  
    16.         ctrl.Attributes["onclick"] = "alert('test');";  
    17.         //add this custom button into the editor as last index  
    18.         Editor1.InsertToolControl(pos, "MyButton", ctrl);  
    19.     }  
    20. </script>  
    21.   
    22. <body>  
    23.     <form runat="server" id="Form1">  
    24.         <CE:Editor ID="Editor1" AutoConfigure="Minimal" runat="server" />  
    25.     </form>  
    26. </body>  
    27. </html>  
     

    Regards,

     

    Ken 

View Complete Thread