简体   繁体   English

在ASP.NET页面中将项目从一个列表拖放到另一个列表?

[英]Dragging & dropping items from one list to another in a ASP.NET page?

I would like to move items from one list to another on a page, and I'm pretty flexible about what type of a list it is. 我想在一个页面上将项目从一个列表移动到另一个列表,而且我对它的列表类型非常灵活。 What's the best way to do that? 最好的方法是什么? ASP.NET Ajax? ASP.NET Ajax? jQuery? jQuery的? Anything else? 还要别的吗?

There's a nice tutorial on CodeProject that covers dragging with ASP.NET and jQuery: CodeProject有一个很好的教程,涵盖了使用ASP.NET和jQuery进行拖动:

http://www.codeproject.com/KB/webforms/JQueryPersistantDragDrop.aspx http://www.codeproject.com/KB/webforms/JQueryPersistantDragDrop.aspx

if you want to do this and PostBack instead of using AJAX to update your data based on from fields you'll need to get creative about what types of controls you use. 如果你想这样做而PostBack而不是使用AJAX来根据你需要的字段来更新数据,你需要了解你使用的控件类型。 Page validation will complain about ASP controls like dropdownlists, listboxes, etc. if they contain selected items that weren't in the list when it was rendered. 页面验证会抱怨ASP控件,如下拉列表,列表框等,如果它们包含在呈现时不在列表中的选定项目。

Better to use AJAX to send back your updates or use HTML controls like unordered lists or select added via javascript and stuff the selected data in another control that doesn't complain (hiddenfield) on PostBack. 最好使用AJAX发回您的更新或使用HTML控件(如无序列表)或选择通过javascript添加并将所选数据填充到另一个不会在PostBack上抱怨(hiddenfield)的控件中。 The alternative is turning off page validation and I don't think that's a good idea. 另一种方法是关闭页面验证,我认为这不是一个好主意。

You can also might look at YUI Library, I'd say it implements Drag & Drop in a very simple and flexible way: http://yuilibrary.com/yui/docs/dd/ 您也可以查看YUI库,我会说它以非常简单灵活的方式实现拖放:http: //yuilibrary.com/yui/docs/dd/

There are a lot of examples etc... 有很多例子......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM