Integrating Drag & Drop with Web Forms

Discussion in 'ASP .Net Web Controls' started by Ed Dennison, Nov 26, 2003.

  1. Ed Dennison

    Ed Dennison Guest

    I am trying to create a simple ASP.NET web page that includes a list
    box into which my user can drag and drop URLs. I want the user to be
    able to easily build a list of URLs by dragging and dropping links
    from other pages onto my page (and also dragging the link from IE's
    Address bar).

    This is what my index.aspx file looks like (in HTML view):

    <%@ Page language="c#" Codebehind="index.aspx.cs"
    AutoEventWireup="false" Inherits="rdmgr.WebForm1" %>
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <SCRIPT language="javascript">
    function SetText()
    {
    window.event.returnValue = false;
    window.event.dataTransfer.dropEffect = "copy";
    var opto = new Option(window.event.dataTransfer.getData("Text"));
    window.document.Form1.Select1.add (opto);
    }
    function OverDrag()
    {
    window.event.returnValue = false;
    }
    </SCRIPT>
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 736px;
    POSITION: absolute; TOP: 88px" runat="server"
    Text="Button" Width="74px" Height="32px"></asp:Button>
    <SELECT id="Select1" style="Z-INDEX: 103; LEFT: 160px; WIDTH:
    480px; POSITION: absolute; TOP: 88px; HEIGHT: 280px"
    size="17" name="Select1" runat="server" ondrop="SetText()"
    ondragover="OverDrag()">
    <OPTION></OPTION>
    </SELECT>
    </form>
    </body>
    </HTML>

    The web page behaves exactly as I desire: when I drag links or URLs
    into the list box, the link text is added to the list. Perfect.

    The problem is, that from the point of view of the C# code, nothing is
    inside the listbox. Specifically, when I handle the Click event for my
    button, the Select1 object has no Items. Also, if I refresh the web
    page, the list contents disappear. And finally, the
    Select1_ServerChange event does not fire when I drag items into the
    list.

    I assume that I am missing some critical piece of glue that causes the
    client side activity in the javascript function to get dispatched to
    the server side. Can anyone tell me what I need to do?

    Thank you!

    Ed Dennison
    E-mail: ed at cognex dot com
     
    Ed Dennison, Nov 26, 2003
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tom
    Replies:
    0
    Views:
    497
  2. tom
    Replies:
    0
    Views:
    446
  3. Dave

    Drag and Drop on Web Forms

    Dave, Dec 31, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    484
    Alvin Bruney
    Dec 31, 2003
  4. =?Utf-8?B?Q0lSRTE5NzU=?=

    Create Drag & Drop Items on ASP.NET web form for End Users

    =?Utf-8?B?Q0lSRTE5NzU=?=, Jul 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    764
    =?Utf-8?B?Q0lSRTE5NzU=?=
    Jul 20, 2004
  5. Loui Mercieca
    Replies:
    2
    Views:
    650
    Loui Mercieca
    Oct 3, 2005
  6. Drag drop in web forms

    , Nov 25, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    520
  7. Oliver Klein
    Replies:
    0
    Views:
    935
    Oliver Klein
    Aug 24, 2003
  8. Author #1
    Replies:
    6
    Views:
    678
    Author #1
    Sep 21, 2009
Loading...