OnKeyup Attaching Events

  •  01-14-2008, 1:06 PM

    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>

     
     
View Complete Thread