将n Drop从DropDownList拖到TextBox

时间:2013-08-19 14:48:49

标签: jquery asp.net

我想在ASP .NET中从DropDownListTextBox实现Drag n'Drop功能。

我将从DropDownList中选择并拖动1个项目并将其放在TextBox上。我尝试过使用jQuery插件,但无济于事。

请参阅下面的标记:

<script type="text/javascript" src="../Scripts/jquery-1.9.1.js"></script>
<script src="../Scripts/ui/jquery-ui.custom.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        DropDown();
        StyleButton();

        $('.dragndrop').draggable();

        $('#<%=TextBox1.ClientID %>').droppable({
            drop: function (ev, ui) {
                ui.draggable.appendTo(this); 
            }
        });
});
<table cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td valign="top" align="left" style="width:200px;">
                            <asp:DropDownList ID="DropDownList1" runat="server" CssClass="dragndrop">
                            </asp:DropDownList>                              
                        </td>
                        <td>
                            <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="80px"
                                Width="250px"></asp:TextBox>

                        </td>
                    </tr>
                </table>

请问我做错了什么?

1 个答案:

答案 0 :(得分:0)

我担心您可以使用本机可拖动机制拖动选项元素。你可以做的是将点击的选项克隆到代表该选项的div中。然后将克隆放在文本框上,并从下拉列表中取消选项。或者你可以通过拖放来查找一个JQuery插件进行下拉操作。