Re: clear editor1 using javascript

  •  02-06-2011, 10:13 PM

    Re: clear editor1 using javascript

    Dear lonnie,
     
    Please refer to the following snippet:
    <%@ Page Language="C#"%>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <html>
    <head>
        <title>ASP.NET WYSIWYG Editor - Carriage Return Example</title>  
    </head>
    <body>
        <form id="Form1" runat="server">
            <table cellpadding="15">
                <tr>
                    <td>
                        <br />
                        <CE:Editor id="Editor1"  ThemeType="Office2007"
                            Height="300" Autoconfigure="Simple" runat="server" />
                        <br />                  
                    </td>
                </tr>
            </table>
        </form>
    </body>
    </html>
    <script type="text/javascript">
        function CuteEditor_OnInitialized(editor) {
            var editor1 = document.getElementById("<%= Editor1.ClientID %>");
            var editdoc = editor1.GetDocument();
            if (editdoc.body.addEventListener) {
                editdoc.addEventListener("focusin", clearContent, false);
            }
            else {
                editdoc.onfocusin = function () {
                    clearContent();
                }
            }
        }
        function clearContent() {
            var editor1 = document.getElementById("<%= Editor1.ClientID %>");
            var text = editor1.getHTML();
            if (text == "Click here to type message") {
                editor1.SetHTML("");
            }
        }         
    </script>
    <script runat="server">
        void Page_Load(object sender, System.EventArgs e)
         {
            if (!IsPostBack)
            {
                Editor1.Text = "Click here to type message";
            }    
        }    
    </script>
    Thank you for asking
    Eric@cutesoft.net 
View Complete Thread