CSS option for Cleaning on Paste does not clean table styles

2 posts, 0 answers
  1. David Tessler
    David Tessler avatar
    23 posts
    Member since:
    Feb 2005

    Posted 12 Jul Link to this post

    What is the best way to remove the style tag from tables (table, tr, td tags)?

    I've been working with the OnClientPasteHtml event but I don't know how to reference the pasted content or the most effective way to accomplish this. Anyone have any ideas?

  2. Nikolay
    Admin
    Nikolay avatar
    64 posts

    Posted 15 Jul Link to this post

    Hello,

    Here is how you can modify the pasted tables using OnClientPasteHtml event:
    <telerik:RadEditor ID="RadEditor1" runat="server" OnClientPasteHtml="OnClientPasteHtml">
    </telerik:RadEditor>
     
    <script type="text/javascript">
        function OnClientPasteHtml(editor, args) {
            if (args.get_commandName() == "Paste") {
                var html = args.get_value();
                var container = document.createElement("div");
                container.innerHTML = html;
                $telerik.$(container).find("table,tbody,thead,tfoot,tr,td,th").each(function (i, item) {
                    item.removeAttribute("style");
                });
                args.set_value(container.innerHTML);
            }
        }
    </script>


    Regards,
    Nikolay
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top