How to get if content of editor updated or not

Last post 09-27-2011, 5:42 AM by DhirajGupta. 3 replies.
Sort Posts: Previous Next
  •  09-26-2011, 7:13 AM 70194

    How to get if content of editor updated or not

    Hi, 
     
    I just want to make a client side validation if content of Editor is updated or not, and on the bases of it need to show a confirmation box.
    Please suggest how it can be achieved.
     
    is there any event or property we can use for the same.
     
    Thanks & Regards 
     
    Dhiraj Gupta 
  •  09-26-2011, 7:50 AM 70197 in reply to 70194

    Re: How to get if content of editor updated or not

    Hi DhirajGupta,
     
    Please try the example below
     
    <%@ Page Language="C#" %>

    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>example</title>
    </head>
    <script runat="server">
        protected override void OnLoad(EventArgs e)
        {
            editor1.Text = "this is a test";
            label1.Text = editor1.Text;
            base.OnLoad(e);
        }
    </script>
    <body>
        <form id="Form1" runat="server">
            <CE:Editor ID="editor1" runat="server">
            </CE:Editor>
            <input type="button" value="check" onclick="check()" /><br />
            click on the button, if you changed the text, it will show a message.
            <asp:Label ID="label1" runat="server" Style="visibility: hidden"></asp:Label>
        </form>
    </body>
    </html>

    <script type="text/javascript">

    var editor1=document.getElementById("<%= editor1.ClientID %>");
    var label1=document.getElementById("<%= label1.ClientID %>");
    function check()
    {

    var str1=label1.innerHTML.toLowerCase();
    var str2=editor1.getHTML().toLowerCase();

    if(!(str1.indexOf(str2)==0 && str2.indexOf(str1)==0))
    {
        alert("text have been changed");
    }
    }
    </script>
     
    Regards,
     
    Ken
  •  09-26-2011, 11:50 AM 70205 in reply to 70197

    Re: How to get if content of editor updated or not

    I am using the editor1.IsDirty() for this. 
     
             function CheckForDirty() {
                var editor1 = document.getElementById("<%= ceEditor1.ClientID %>");
                    if (editor1.IsDirty()) {
                        alert("text has been changed");
                    }
            }
     
    Is there a reason I should not be using this function and do external comparisons instead?

    The Analytical Group
  •  09-27-2011, 5:42 AM 70213 in reply to 70205

    Re: How to get if content of editor updated or not

    I was looking for the same ,Thanks TAG :)
View as RSS news feed in XML