FixRangePasteBug error in PasteHTML

Last post 11-07-2013, 12:13 AM by Adam. 2 replies.
Sort Posts: Previous Next
  •  11-06-2013, 10:27 AM 78311

    FixRangePasteBug error in PasteHTML

    Using the current asp.net demo version of CuteEditor, win8, IE10, vs2012.

     

    Example code:

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Cutest._Default" %>

    <%@ 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></title>

    </head>

    <body> 

       <form id="form1" runat="server">

        <div> 

         <CE:Editor id="Editor1" ThemeType="Custom" runat="server">      </CE:Editor>

        </div> 

       </form> 

    <input type="button" value="Test Paste" onclick="test()" />

    </body></html>

    <script type="text/javascript">  

    function test()  {    var ed = document.getElementById('<%= Editor1.ClientID%>');    

    ed.PasteHTML('this is a test');  }

    </script>

     

    Clicking the 'Test Paste' button to insert 'this is a test' into the document works until the editor is manually edited and then the following error occurs:

     

    Unhandled exception at line 3, column 155297 in eval code

    0x80004005 - JavaScript runtime error: Unspecified error. 

     

    The error is on the line Oxa.pasteHTML(FixRangePasteBug(Ox142));
     

    NB pressing backspace in here keeps messing up the html! (e.g. press space and backspace inserts '&amp;amp;lt;br&amp;amp;gt;'. I also had a lot of fun getting the above code to paste in properly as it removed all line breaks + the cursor kept jumping around all over the place. (made this post in FF 25.0)<br>

    Filed under: ,
  •  11-06-2013, 11:01 AM 78312 in reply to 78311

    Re: FixRangePasteBug error in PasteHTML

    Finally fixed this after several hours of forum searching and trial and error (the documentation on the client scripting side of things is virtually non-existant). You need to call 'FocusDocument' prior to doing the paste as the editor window seems to lose focus.

     

    i.e.:

     

       function test()
      {
        var ed = document.getElementById('<%= Editor1.ClientID%>');
        ed.FocusDocument();
        ed.PasteHTML('this is a test');
      }

  •  11-07-2013, 12:13 AM 78314 in reply to 78312

    Re: FixRangePasteBug error in PasteHTML

    Symo:

    Finally fixed this after several hours of forum searching and trial and error (the documentation on the client scripting side of things is virtually non-existant). You need to call 'FocusDocument' prior to doing the paste as the editor window seems to lose focus.

     

    i.e.:

     

       function test()
      {
        var ed = document.getElementById('<%= Editor1.ClientID%>');
        ed.FocusDocument();
        ed.PasteHTML('this is a test');
      }

     

    Thanks for the input.  We will add this into the document. 


    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