Javascipt attachevent lost on postback

Last post 05-24-2007, 1:45 PM by Adam. 1 replies.
Sort Posts: Previous Next
  •  05-24-2007, 5:42 AM 30037

    Javascipt attachevent lost on postback

    I'm currently evaluating CuteEditor and have a snag with js events and postbacks.
     
    In essence, when the page intitially loads, I can attach events fine, it works. However, once the page has been posted back, the events are not attached (unless the text in the cute editor has changed).
     
    From what I can gather, the CuteEditor_OnInitialized event is not firing when the text has not been changed on postback.
     
    Any ideas?

    function check(evt, editorId)
    {
     alert('keypressed');
     return true;
    }

    function InitializeEditor(editorId)
    {
     var editor1 = document.getElementById(editorId);
     var editdoc = editor1.GetDocument();
     editdoc.attachEvent('onkeypress',function x(){return check(event, editorId);} );
    }

    function CuteEditor_OnInitialized(e)
    {
       InitializeEditor(e.id);
    }

    Scott

  •  05-24-2007, 1:45 PM 30052 in reply to 30037

    Re: Javascipt attachevent lost on postback

    Scott,
     
    Please try the following code:
     

    <script language="JavaScript" type="text/javascript" >
      var editor1=document.getElementById("<%=Editor1.ClientID%>");
      if(editor1.IsReady)CuteEditor_OnInitialized(editor);
      function CuteEditor_OnInitialized(editor)
      { 
       var editdoc = editor1.GetDocument();
       editdoc.attachEvent('onkeypress',function x(){return check(event);} );
      }
     
      function check(evt)
      {
       alert('keypressed');
       return true;
      }

    </script>
     
     

    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

View as RSS news feed in XML