Re: Custom dialog button with multiple RichTextEditors on the same page

  •  03-14-2014, 8:01 AM

    Re: Custom dialog button with multiple RichTextEditors on the same page

    hi fulles,

     

    Please try the new one below. Two editors has its own custom button.

     

    1. <%@ Page Language="c#" %>  
    2.   
    3. <%@ Register TagPrefix="RTE" Namespace="RTE" Assembly="RichTextEditor" %>  
    4.   
    5. <script runat="server">  
    6.     protected override void OnInit(EventArgs e)  
    7.     {  
    8.         base.OnInit(e);  
    9.   
    10.         Editor1.ToolbarItems = "{unlink,removeformat}//{mybutton1}";  
    11.         Editor2.ToolbarItems = "{unlink,removeformat}//{mybutton2}";  
    12.     }  
    13.   
    14. </script>  
    15.   
    16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    17. <html xmlns="http://www.w3.org/1999/xhtml">  
    18. <head>  
    19.     <title>RichTextEditor - Custom buttons</title>  
    20.     <link rel="stylesheet" href="../example.css" type="text/css" />  
    21. </head>  
    22. <body>  
    23.     <form id="Form1" method="post" runat="server">  
    24.         <p>  
    25.             <RTE:Editor runat="server" ID="Editor1" />  
    26.             <br /><br />  
    27.             <RTE:Editor runat="server" ID="Editor2" />  
    28.         </p>  
    29.           
    30.     </form>  
    31. </body>  
    32. </html>  
    33.   <script type="text/javascript">  
    34.       var editor1;  
    35.       var editor2;  
    36.       function RichTextEditor_OnLoad(editor) {  
    37.           if (editor._config.uniqueid == "Editor1") {  
    38.               editor1 = editor;  
    39.           }  
    40.           if (editor._config.uniqueid == "Editor2") {  
    41.               editor2 = editor;  
    42.           }  
    43.           
    44.       }  
    45.       function RichTextEditor_OnCoreLoad(rteloader) {  
    46.           var config = rteloader._config;  
    47.           if (config.uniqueid == "Editor1") {  
    48.               var config = rteloader._config;  
    49.               var toolbar = config._toolbartemplate || config.toolbar;  
    50.               //mybutton1 is added in Editor1.ToolbarItems  
    51.               var btnname = "item_" + toolbar + "_" + config.skin + "_" + config.color + "_mybutton1";  
    52.               var basetype = "image_" + config.skin + "_" + config.color;  
    53.   
    54.               var define = jsml.class_define(btnname, basetype);  
    55.               define.constructor(function () {  
    56.                   this[basetype + "_constructor"]();  
    57.                   this.set_imagename("openfolder");  
    58.                   this.set_tooltip("My custom button!");  
    59.               });  
    60.               define.attach("click", function () {  
    61.                   editor1.InsertHTML("editor1");  
    62.               });  
    63.           }  
    64.   
    65.           if (config.uniqueid == "Editor2") {  
    66.               var config = rteloader._config;  
    67.               var toolbar = config._toolbartemplate || config.toolbar;  
    68.               //mybutton2 is added in Editor1.ToolbarItems  
    69.               var btnname = "item_" + toolbar + "_" + config.skin + "_" + config.color + "_mybutton2";  
    70.               var basetype = "image_" + config.skin + "_" + config.color;  
    71.   
    72.               var define = jsml.class_define(btnname, basetype);  
    73.               define.constructor(function () {  
    74.                   this[basetype + "_constructor"]();  
    75.                   this.set_imagename("openfolder");  
    76.                   this.set_tooltip("My custom button!");  
    77.               });  
    78.               define.attach("click", function () {  
    79.                   editor2.InsertHTML("editor2");  
    80.               });  
    81.           }  
    82.   
    83.       }  
    84.   
    85.         </script>  
     

    Regards,

     

    Ken 

View Complete Thread