Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Drag and Drop in ASP.NET

Drag and Drop in ASP.NET

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-nethelpannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Larza123
    wrote on last edited by
    #1

    Hi! I have created a drag and drop function for some of the label objects on my page. It workes like this. When I click on the mousebutton I look for the object that was clicked on and then I create a DIV that contains the same text and that follows the mouse pointer until I release the mouse button. My problem is that I am trying to do the same with an image but when i click on an image and move the mouse with the button down it tries to move the image and instead of moving my DIV it moves a circle with a line through it. Does anyone know how I can get around that? Is there a way to drop an object that I'm trying to drag so I can drop the circle and pickup my DIV? If the question was difficult to understand so please tell me and i will rewrite it. Thanx!

    L 2 Replies Last reply
    0
    • L Larza123

      Hi! I have created a drag and drop function for some of the label objects on my page. It workes like this. When I click on the mousebutton I look for the object that was clicked on and then I create a DIV that contains the same text and that follows the mouse pointer until I release the mouse button. My problem is that I am trying to do the same with an image but when i click on an image and move the mouse with the button down it tries to move the image and instead of moving my DIV it moves a circle with a line through it. Does anyone know how I can get around that? Is there a way to drop an object that I'm trying to drag so I can drop the circle and pickup my DIV? If the question was difficult to understand so please tell me and i will rewrite it. Thanx!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi maybe this can help...it moves the div with the img inside var x=y=o=null; if (document.layers) { window.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP); window.onmousedown=down, window.onmouseup=up, window.onmousemove=move; } else if (document.all) document.onmousedown=down, document.onmouseup=up, document.onmousemove=move; function down(e) { if (document.all && window.event.srcElement.parentElement) o=window.event.srcElement.parentElement, x=window.event.offsetX, y=window.event.offsetY; else { if (document.layers) { if (document.layers['o'+e.target.name]) { o=document.layers['o'+e.target.name], x=e.layerX, y=e.layerY; } else return true; } } return false; } function move(e) { if (document.all && o) o.style.posLeft=window.event.clientX-x, o.style.posTop=window.event.clientY-y; else if (document.layers && o) o.left=e.pageX-x, o.top=e.pageY-y; return false; } function up() { document.getElementById('o1').style.visibility="hidden"; o=null; } function coordinates(el) { switch (event.type) { case "click": el.style.visibility = "visible"; el.style.posTop = event.y-10; el.style.posLeft = event.x-30; break; } }

      :sigh: vbturbo -- modified at 16:31 Wednesday 19th October, 2005 "

      "

      1 Reply Last reply
      0
      • L Larza123

        Hi! I have created a drag and drop function for some of the label objects on my page. It workes like this. When I click on the mousebutton I look for the object that was clicked on and then I create a DIV that contains the same text and that follows the mouse pointer until I release the mouse button. My problem is that I am trying to do the same with an image but when i click on an image and move the mouse with the button down it tries to move the image and instead of moving my DIV it moves a circle with a line through it. Does anyone know how I can get around that? Is there a way to drop an object that I'm trying to drag so I can drop the circle and pickup my DIV? If the question was difficult to understand so please tell me and i will rewrite it. Thanx!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        dont know what went wrong....but add this also DIV id="o1" style="Z-INDEX: 999; LEFT: 240px; VISIBILITY: hidden; WIDTH: 80px; POSITION: absolute; TOP: 400px; HEIGHT: 19px; BACKGROUND-COLOR: #ccccff" align="justify" runat="server">

        L 1 Reply Last reply
        0
        • L Lost User

          dont know what went wrong....but add this also DIV id="o1" style="Z-INDEX: 999; LEFT: 240px; VISIBILITY: hidden; WIDTH: 80px; POSITION: absolute; TOP: 400px; HEIGHT: 19px; BACKGROUND-COLOR: #ccccff" align="justify" runat="server">

          L Offline
          L Offline
          Larza123
          wrote on last edited by
          #4

          Thanx for your reply. I have allready done the way you wrote. The problem is that I can't place the image in a DIV because I'm using Microsofts TreeView and I have done a drag and drop funktion for the TreeView so that I can move nodes around in the tree. It works if I click on the text on a node because that is just an A-tag. But I also want to be able to click on the folder image that I have on each node but then It happens as I described in my earlier message. (When I click on the A-tag I create a DIV that moves around with the mouse and because an A-tag doesn't have a function for click and hold the A object nothing more than my DIV is hold by the mouse. But the IMG object has some kind of function for click and hold the IMG object but it is not posible to move the IMG so I get a forbidden sign instead of my DIV for some reason. When i release the mouse button my DIV follows the mouse and that is not what I want. Do you or anyone else know if I can drop the IMG object holder and show my DIV instead or if I can do it in some other way for this purpose.) Thanx!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups