Disable Images Drag and Drop

11 posts, 0 answers
  1. Babar Khan Khalil
    Babar Khan Khalil avatar
    9 posts
    Member since:
    Mar 2006

    Posted 04 Sep 2009 Link to this post

    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.
  2. Rumen
    Admin
    Rumen avatar
    13749 posts

    Posted 04 Sep 2009 Link to this post

    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.
  3. Babar Khan Khalil
    Babar Khan Khalil avatar
    9 posts
    Member since:
    Mar 2006

    Posted 04 Sep 2009 Link to this post

    Hi Rumen,

    this works fine in IE but not working in Firefox
  4. Rumen
    Admin
    Rumen avatar
    13749 posts

    Posted 04 Sep 2009 Link to this post

    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.
  5. arnaud
    arnaud avatar
    105 posts
    Member since:
    Jul 2008

    Posted 12 May 2010 Link to this post

    Hi,

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

    Thank You

  6. Rumen
    Admin
    Rumen avatar
    13749 posts

    Posted 12 May 2010 Link to this post

    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.
  7. arnaud
    arnaud avatar
    105 posts
    Member since:
    Jul 2008

    Posted 12 May 2010 Link to this post

    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
  8. Rumen
    Admin
    Rumen avatar
    13749 posts

    Posted 12 May 2010 Link to this post

    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.
  9. arnaud
    arnaud avatar
    105 posts
    Member since:
    Jul 2008

    Posted 12 May 2010 Link to this post

    Thank you Rumen.
  10. ratnesh
    ratnesh avatar
    1 posts
    Member since:
    Jun 2010

    Posted 02 Aug 2011 Link to this post

    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
  11. Rumen
    Admin
    Rumen avatar
    13749 posts

    Posted 04 Aug 2011 Link to this post

    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.

Back to Top