PasteHTML issue

  •  11-07-2011, 12:08 PM

    PasteHTML issue

    I am using PasteHTML in javascript to insert a block of HTML code in to the editor that contains a table.
      
    This is the javascript code:
     
    var edtEmail = document.getElementById('<%= edtEmail.ClientID %>');
    edtEmail.ExecCommand('PasteHTML', false, arg.html);
    The problem is that if I insert another table, the html code gets inserted inside the last column of the first table just inserted instead of inserting the table in a new line.
     
    I tried different things, and adding a <br> after the first table seems to place the table in the right position, but the problem is that the second table doesn't display until I go to "preview" or "html" tab. Then if I come back to the Edit tab, it works fine.
     
    This is the additional line I added after the above 2 lines.
    edtEmail.ExecCommand('PasteHTML', false, "<br>");
     
     Is there a way to refresh the editor or force it to display the html? Also, any idea how to set the cursor position? Why doesn't PasteHTML work properly, and why does it seem to paste the second table in the wrong position? If I manually place the cursor somewhere, and use PasteHTML, it places the second table in the right place.
     
    Here is an example of the html code being inserted:
     
     
    <table style="border-width: 1px; border-style: solid; width: 100%; font-size: 10pt; border-collapse: collapse; table-layout: auto;">
    <tbody>
    <tr>
    <td rowspan="4"><img src="https://www.car-research.com/carinteractive/vimages/807/T11146A/329f6cda-5ef9-4137-8e64-4033eaaa0026.jpg" width="120" alt="" /></td>
    <td><strong>2006 FORD F150 Harley-Davidson</strong></td>
    <td>Exterior Color: Black - (Black)</td>
    <td style="font-size: large;" rowspan="4"><strong>$27,995.00</strong></td>
    </tr>
    <tr>
    <td>VIN: 1FTRX14526FA00778</td>
    <td>Interior Color: Black Leather</td>
    </tr>
    <tr>
    <td>Stock #: T11146A</td>
    <td>Engine: 5.4L</td>
    </tr>
    <tr>
    <td>Miles: 58636</td>
    <td>Transmission: Automatic</td>
    </tr>
    </tbody>
    </table>
     
     
View Complete Thread