Re: PasteHTML issue

  •  11-08-2011, 3:16 PM

    Re: PasteHTML issue

    Hi Ken
     
    Thanks for your reply.
     
    Actually on my end, I can easily reproduce the problem with the code you sent! If you press the "Set Table" button multiple times, the new tables start getting inserted inside the first ones after a couple of clicks.
     
    I modified your example a little bit to insert the table I'm inserting, and you can test it to see it keeps inserting within the table.
     
    If you place the cursor inside the first table, and then press "Set Table" button multiple times, you will see it keeps getting inserted inside the first table that was inserted.
     
    Actually, you don't even need the original table and the insert command does not have to be inside a table (the editor text can be blank), and the same thing still happens.
     
    Here is the code:
     
    1.     <input type="button" value="Set Table" onclick="setTable()" />  
    2.     <br />  
    3.     <CE:Editor ID="edtEmail" runat="server" Width="100%" Height="520px" AutoConfigure="Simple"  
    4.         ThemeType="Office2007" URLType="Absolute" EnableStripStyleTagsCodeInjection="False" />  
    5. </div>  
    6. <script type="text/javascript">  
    7.     var myTable = '<table bgcolor="#ffffff">' +  
    8.     '    <tbody>' +  
    9.     '        <tr>' +  
    10.     '            <td valign="top" align="center">' +  
    11.     '            <table border="0" cellspacing="0" cellpadding="0" width="600" bgcolor="#ffffff">' +  
    12.     '                <tbody>' +  
    13.     '                    <tr>' +  
    14.     '                        <td style="width: 608px; height: 19px;" align="center">' +  
    15.     '                        <div align="center">&nbsp;</div>' +  
    16.     '                        </td>' +  
    17.     '                    </tr>' +  
    18.     '                    <tr>' +  
    19.     '                        <td align="left"></td>' +  
    20.     '                    </tr>' +  
    21.     '                </tbody>' +  
    22.     '            </table>' +  
    23.     '        </tr>' +  
    24.     '    </tbody>' +  
    25.     '</table>';  
    26.   
    27.     var insertItem = '<table style="border-width: 1px; border-style: solid; width: 100%; font-size: 10pt;' +  
    28.     '   border-collapse: collapse; table-layout: auto;">' +  
    29.     '   <tbody>' +  
    30.     '       <tr>' +  
    31.     '           <td rowspan="4">' +  
    32.     '               <img src="https://www.car-research.com/carinteractive/vimages/79/C5181/06528ba2-a0fa-435e-819d-596bcfeb2859.jpg"' +  
    33.     '                   width="120" alt="" />' +  
    34.     '           </td>' +  
    35.     '           <td>' +  
    36.     '               <strong><a href="http://www.car-research.com/carinteractive/WebXRM/Vehicle/VehicleEBrochure.aspx?xdealerid=79&amp;stocknum=C5181"' +  
    37.     '                   target="_blank">2009 Mazda RX8 COUPE 4 DOOR </a></strong>' +  
    38.     '           </td>' +  
    39.     '            <td>' +  
    40.     '                Exterior Color: Velocity Red' +  
    41.     '            </td>' +  
    42.     '            <td style="font-size: large;" rowspan="4">' +  
    43.     '                <strong>$27,500.00</strong>' +  
    44.     '            </td>' +  
    45.     '        </tr>' +  
    46.     '        <tr>' +  
    47.     '            <td>' +  
    48.     '                VIN: JM1FE17P790401904' +  
    49.     '            </td>' +  
    50.     '            <td>' +  
    51.     '                Interior Color: Black Cloth' +  
    52.     '            </td>' +  
    53.     '        </tr>' +  
    54.     '        <tr>' +  
    55.     '            <td>' +  
    56.     '                Stock #: C5181' +  
    57.     '            </td>' +  
    58.     '            <td>' +  
    59.     '                Engine: Rotary engine' +  
    60.     '            </td>' +  
    61.     '        </tr>' +  
    62.     '        <tr>' +  
    63.     '            <td>' +  
    64.     '                Miles: 19' +  
    65.     '            </td>' +  
    66.     '            <td>' +  
    67.     '                Transmission:' +  
    68.     '            </td>' +  
    69.     '        </tr>' +  
    70.     '    </tbody>' +  
    71.     '</table>';  
    72.   
    73.     function CuteEditor_OnInitialized(editor) {  
    74.         editor.ExecCommand('PasteHTML'false, myTable);  
    75.     }  
    76.     function setTable() {  
    77.   
    78.         var editor1 = document.getElementById("<%= edtEmail.ClientID %>");  
    79.         editor1.ExecCommand('PasteHTML'false, insertItem);  
    80.   
    81.     }  
    82. </script>  
    Filed under: ,
View Complete Thread