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

Disable Images Drag and Drop

10 Answers 130 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Babar Khan Khalil
Top achievements
Rank 1
Babar Khan Khalil asked on 04 Sep 2009, 10:01 AM
Hi,

how to disable the Drag and drop feature for images in RadEditor. Currently , i can drag any image in my web page and drop this to Rad Editor. how to disable that ? but at the same time i want the copy/paste functionality for images in rad editor.

10 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 04 Sep 2009, 10:08 AM
Hi Babar Khan Khalil,

You can disable the drag and drop operations in the editor content area using the following code:

<script type="text/javascript">     
function OnClientLoad(editor, args)     
{     
   var element = document.all ? editor.get_document().body : editor.get_document();     
   var eventHandler  = document.all ? "drop" : "dragstart";     
   var selElem  = editor.getSelectedElement(); 
   $telerik.addExternalHandler(element, eventHandler, function(e)     
   {     
             $telerik.cancelRawEvent(e); 
             return false
   });    
}     
  
</script>    
<telerik:radeditor runat="server"    
   OnClientLoad="OnClientLoad"  
   ID="RadEditor1">    
   <Content><img src="/mdc-logo.png" />test test test</Content>  
</telerik:radeditor>  


Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Babar Khan Khalil
Top achievements
Rank 1
answered on 04 Sep 2009, 10:24 AM
Hi Rumen,

this works fine in IE but not working in Firefox
0
Rumen
Telerik team
answered on 04 Sep 2009, 12:26 PM
Hi,

You should upgrade your Firefox to the latest version 3.5.2, because the dragstart event is new for Firefox 3 and it is not supported by the old Firefox version.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
arnaud
Top achievements
Rank 1
answered on 12 May 2010, 01:29 PM
Hi,

Using Firefox 3.6.3 and Telerik 2010.1.309.35 it's not working.

Thank You

0
Rumen
Telerik team
answered on 12 May 2010, 01:41 PM
Hi Arnaud,

I tested the code and it works as expected in Firefox 3.6.3. Please, see the attached video at http://screencast.com/t/YzhhMTE0O which demonstrates my test. Am I missing something?

Best regards,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
arnaud
Top achievements
Rank 1
answered on 12 May 2010, 01:50 PM
Hi Rumen,

Thanks for the quick answer.

Try to do the same but take your text/image/whatever from outside the RadEditor and drop it inside the RadEditor content. I want to disable such drag& drop.

Hope i'm clear

Thank You
0
Rumen
Telerik team
answered on 12 May 2010, 01:56 PM
Hi Arnaud,

I am afraid that such prevention is not supported by the Firefox browser JavaScript API. You can prevent the drag and drop only inside the content area but not from outside. The content area of RadEditor is an editable IFRAME and Firefox does not offer a way to disable the insertion of elements from outside in the editable IFRAME elements.

For your convenience I have attached an HTML page with an editable IFRAME in it. If you would like you can experiment with the page and if you are able to implement a solution, find  a workaround or hack in another site just send us the working solution and we will integrate it in RadEditor.


Kind regards,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
arnaud
Top achievements
Rank 1
answered on 12 May 2010, 02:09 PM
Thank you Rumen.
0
ratnesh
Top achievements
Rank 1
answered on 02 Aug 2011, 06:55 AM
I use the following code to disable the drop .
This works across all the browser.
can you think of any consequences of using this ?

<div onmousedown="return false;">
        <telerik:RadEditor
0
Rumen
Telerik team
answered on 04 Aug 2011, 01:33 PM
Hi Ratnesh,

Thanks for sharing this solution. There shouldn't be side effects.

Note that only the contents placed inside the <div onmousedown="return false;"> will be unselectable. The users will be able to drag content placed outside of the div.

All the best,
Rumen
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
Babar Khan Khalil
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Babar Khan Khalil
Top achievements
Rank 1
arnaud
Top achievements
Rank 1
ratnesh
Top achievements
Rank 1
Share this question
or