This is a migrated thread and some comments may be shown as answers.

How to capture Rad Editor Text after paste command

1 Answer 79 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Krishnakanth
Top achievements
Rank 1
Krishnakanth asked on 17 Feb 2009, 01:57 PM
HI all,
i need to capture the new content of the editor in paste command.
i checked all the forums and i didn't get any solution for this.
please help me in this issue.
in which i can get the new value of editor.


Thanks & Regards,
Krishnakanth

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 20 Feb 2009, 12:17 PM
Hi Krishnakanth,

In the upcoming Q1 2009 "Futures" release of RadControls for ASP.NET AJAX, the OnClientPasteHtml event of RadEditor will be fired when the onpaste browser event is executed. This will allow the developer to obtain and modify / clean only the pasted, but not the whole content inside the editor.

Here is a sample example that demonstrates how to attach to the Paste command:
 
<script type="text/javascript"
function OnClientPasteHtml(sender, args) 
    var commandName = args.get_commandName(); 
    var value = args.get_value(); //this is the pasted content 
    if (commandName == "Paste") 
    { 
           alert("original pasted content: " + value); 
            var newContent = "modified content"; //write here a regular expression that will strip the <h1><h2><h3>, etc tags  
            alert("modified pasted content" + newContent); 
            args.set_value(newContent);  //insert the modified content in the editor 
     } 
</script> 
<telerik:RadEditor runat="server" 
    OnClientPasteHtml="OnClientPasteHtml" 
    ImageManager-ViewPaths="~/" 
    ID="RadEditor1"
</telerik:RadEditor>    


The onpaste event will be executed only when the StripFormattingOptions property is not set to NoneSupressCleanMessage, because then the editor does not execute any code to handle the pasted content and it is pasted without modifications by the browser itself.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Krishnakanth
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or