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

onbeforepaste event handler does not seem to work

1 Answer 134 Views
Editor
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 17 Dec 2010, 09:56 PM
onbeforepaste does not seem to work when attatched (client side) at the OnClientLoad_RadEditor event.  If I change 'onbeforepaste' to 'onclick' it works. My goal is to eventually prevent when certain conditions exist.

function OnBeforePaste_Editor(e){
    debugger;
    alert("paste attempted");
    e.returnValue=false; /* disable pasting to test*/
}
function OnClientLoad_RadEditor(editor, args) {
    editor.attachEventHandler("onbeforepaste", OnBeforePaste_Editor);
    ...
}

Relevant links
onbeforepaste event
all dhmtl events
radeditor example on attatching onkeypress event


Thanks in advance,

John

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 22 Dec 2010, 03:25 PM
Hi John,

It is not possible to assign handlers to the onbeforepaste / onafterpaste DOM events because they are handled by the editor itself to perform various manipulations to the pasted content.

In order to prevent pasting of content into the RadEditor's content area you can use its OnClientPasteHtml event, e.g.:
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientPasteHtml="OnClientPasteHtml">
</telerik:RadEditor>
 
<script type="text/javascript">
    function OnClientPasteHtml(editor, args)
    {
        alert("paste attempted");
        args.set_cancel(true); //cancel further execution
    }
</script>


All the best,
Dobromir
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Editor
Asked by
John
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or