Turn Off Drag/Drop From Code-behind

3 posts, 0 answers
  1. Richard
    Richard avatar
    17 posts
    Member since:
    Dec 2008

    Posted 20 Aug 2013 Link to this post


    I have a case where I want to disable Drag and Drop based on whether the user is accessing my site from a laptop or mobile device.  If it's Mobile, I want to disable it.

    I thought that the OnInit event would be the right place to do this.  Could someone point me in the right direction for this?

    protected void ItemTree_Init(object sender, EventArgs e)
        var browsersniff = Request.Browser;
            if (browsersniff.IsMobileDevice == true)
                this.ItemTree.EnableDragAndDrop = false;
                this.ItemTree.EnableDragAndDropBetweenNodes = false;


     (Edit: I should add that the code above does get hit when I run on the debugger.  It just isn't disabling Drag/Drop)


  2. Bozhidar
    Bozhidar avatar
    1146 posts

    Posted 23 Aug 2013 Link to this post

    Hello Richard,

    I've tested the described scenario, but it worked fine on my end. I've attached the sample page I used. Could you run it on your end and see if the issue reproduces? If the page is missing some important part of your project that's needed for reproducing the issue, please modify it accordingly and send back the modified code, so that we can inspect it locally.

    Could you also specify what mobile device you are using for testing?

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. Richard
    Richard avatar
    17 posts
    Member since:
    Dec 2008

    Posted 23 Aug 2013 Link to this post

    Thank you for this...

    Our page is way, way more complicated than that.  :-)  But, since your example worked, I think it's something in our initialization code someplace else that might be causing this issue.

    I decided to try in our OnTreeLoad javascript handler and I was successful (code below).

    For the most part - our users carry iPads, but we want to disable Drag/drop for all mobile device users.  We are testing with the iPad and Kindle HD.

    Thanks for your help!

    if ("<%=ismobile %>" == "True") {
Back to Top