Live Support, Chat, Upload Control and Rich Text Editor
Welcome to Support forums Sign in | Join | Help |Client Center
in Search

OnKeyup Attaching Events

Last post 05-28-2008, 1:26 PM by Mstanglx. 2 replies.
Sort Posts: Previous Next
  •  01-14-2008, 1:06 PM 36298

    OnKeyup Attaching Events

    The example @ http://cutesoft.net/example/JavaScript-API.aspx does not work for me either. I followed the source code and cannot get it to fire my custom events for onkeyup here is the code: ASP.Net 2.0 C#. Also adding them programmatically via code behind does not work (Editor1.Attributes.Add("onmouseleave","alert('mouse left');");
     
    If i call attach events in the body onload i get errors, and i want it to automatically attach events.
     
    Please advise!
     

    <%@ page language="C#" autoeventwireup="true" validaterequest="false" codebehind="WebForm1.aspx.cs" inherits="WebApplication1.WebForm1" %>

    <%@ 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 runat="server">
      <title>Untitled Page</title>
      <script language="javascript" type="text/javascript">
      function SetButtonStates()
      {
      }
        
      function attachevents()
      {
        // get the cute editor instance
        var editor1 = document.getElementById('Editor1');
        
        //Get the editor content 
        var editdoc=editor1.GetDocument();

        // attach Event
        if(editdoc.attachEvent)
         editdoc.attachEvent('onkeyup',ActionText_OnKeyUp);
        else if(editdoc.addEventListener)
         editdoc.addEventListener('onkeyup',ActionText_OnKeyUp,true);
         
         // attach Event
        if(editdoc.attachEvent)
         editdoc.attachEvent('onfocus',ActionText_OnFocus);
        else if(editdoc.addEventListener)
         editdoc.addEventListener('onfocus',ActionText_OnFocus,true);
      }
      
      function ActionText_OnMouseLeave()
      {
       alert('mouseleave');
       ActionText_OnKeyUp();
      }
        
      function ActionText_OnFocus()
      {
       alert('onfocus');
       document.getElementById("<%=Editor1.ClientID %>").select()
      }

      function ActionText_OnKeyUp()
      {
       alert('keyup');
       SetButtonStates();
      }

      </script>
     </head>
     <body onload="attachevents()">
      <form method="post" runat="server" action="">
       <table>
        <tr>
         <td>
          CuteSoft CuteEditor
         </td>
        </tr>
        <tr>
         <td>
          <ce:editor id="Editor1" editorwysiwygmodecss="example.css" runat="server">
          </ce:editor>
          <br />
         </td>
        </tr>
        <tr>
         <td>
          <input type="text" runat="server" id="myinput" />
         </td>
        </tr>
         </table>
      </form>
     </body>
    </html>

     
     
  •  01-15-2008, 10:09 AM 36326 in reply to 36298

    Re: OnKeyup Attaching Events

        // get the cute editor instance
        var editor1 = document.getElementById('Editor1');
     
    Should be:
     
    // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  05-28-2008, 1:26 PM 40857 in reply to 36326

    Re: OnKeyup Attaching Events

    I am revisiting using cute editor again, i have the corrected code as stated above. The events attach...I also have attached a keypress event. Now every onkeypress event now fires both an onmouseleave and an onkeypress event. I also cannot get an onkeyup event to fire...here is the code now:
     
     
     <script type="text/javascript">
     
       setTimeout(CE_attachEvent,1000);  
          
       function CE_attachEvent()
       {
         // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        
        //Get the editor content 
        var editdoc=editor1.GetDocument();
          
        // attach Event
        if(editdoc.attachEvent)
        {
         //editor1.attachEvent('onfocus',HandleChange);
         editor1.attachEvent('onmouseleave',HandleChange);
         editdoc.attachEvent('onkeypress',HandleChange);
         editdoc.attachEvent('onkeyup',HandleChange);

         }
         else if(editdoc.contentDocument.addEventListener)
         {
         //editor1.contentDocument.addEventListener('focus',HandleChange,true);
         editor1.contentDocument.addEventListener('mouseleave',HandleChange,true);
         editdoc.addEventListener('keypress',HandleChange,true);
         editdoc.addEventListener('keyup',HandleChange,true);
        }
       }  
     
       function HandleChange(eventFired)
       {
        alert(eventFired.type);
        }
     
      </script>

View as RSS news feed in XML
Powered by ASP.Net
Copyright 2003 - 2017 CuteSoft Components Inc.. All rights reserved.