Problems with catching client side OnChange in Event

Last post 11-20-2013, 7:35 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  11-20-2013, 5:48 AM 78394

    Problems with catching client side OnChange in Event

     Hey guys!

     

    I need to handle the change event, when the textarea of CE gets an input (keydown).  A flag should be set and triggers a notification which informs the user about unsaved changes.

     

    I found the follwing code snippets, but they dont work for me. I dont know why. Or  do i misuse it?

    editor.ID = "rtfDocumentEditor"

     

    function CuteEditor_OnChange(rtfDocumentEditor) {

          checkIsDirty();  

    }

     

    var rtfDocumentEditor = document.getElementById("<% = rtfDocumentEditor.ClientID %>"); 

    function checkIsDirty() { 

          if (rtfDocumentEditor.IsDirty() == true) {

                alert("Unsaved Changes");

          }

    }

     

  •  11-20-2013, 7:35 AM 78395 in reply to 78394

    Re: Problems with catching client side OnChange in Event

    Hi,

     

    Please try the example below

     

    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register Namespace="CuteEditor" Assembly="CuteEditor" TagPrefix="CE" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5.   
    6. <script runat="server">  
    7.     protected override void OnLoad(EventArgs e)  
    8.     {  
    9.         editor1.Text = "change something here..";  
    10.         base.OnLoad(e);  
    11.     }  
    12. </script>  
    13.   
    14. <html xmlns="http://www.w3.org/1999/xhtml">  
    15. <head id="Head1" runat="server">  
    16.     <title>Untitled Page</title>  
    17. </head>  
    18. <body>  
    19.     <form id="form1" runat="server">  
    20.         <div>  
    21.             <CE:Editor ID="editor1" runat="server">  
    22.             </CE:Editor>  
    23.             <input type="button" value="check is dirty" onclick="checkIsDirty()" />  
    24.             <script>  
    25.             var editor1=document.getElementById("<%= editor1.ClientID %>");  
    26.             function checkIsDirty()  
    27.             {  
    28.                 if(editor1.IsDirty())  
    29.                 {  
    30.                     alert("is dirty");  
    31.                 }  
    32.             }  
    33.             function CuteEditor_OnChange(editor)  
    34.             {   
    35.               checkIsDirty();  
    36.             }  
    37. </script>  
    38.   
    39.         </div>  
    40.     </form>  
    41. </body>  
    42. </html>  
     

    Regards,

     

    Ken 

View as RSS news feed in XML