Click here to Skip to main content
15,921,174 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<big> i want to drag and drop the list item from one list box to other. the list item should get copied in the other list box </big>
thanks.
Posted

1 solution

You can use jquery ......
See following code we can get value of div or other as follows

JavaScript
= $(this).attr('id');

 =$(source).find('p:first').text();
 =$(source).find('p').text();


I am using following .js  file for drag and drop

<script type="text/javascript" src="js/jquery.easyui.min.js"></script>

JavaScript
<![CDATA[<%--Code for Drag and Drop Start--%>]]>
	<style type="text/css">
	    .dragR{
			width:auto;
			height:auto;
			cursor:move;
		}
		.drag{
			width:150px;
			height:20px;
			cursor:move;
			border:1px solid #ccc;
			background:#AACCFF;
		}
		.dp{
			opacity:0.5;
			filter:alpha(opacity=50);
		}
		.over{
			background:#FBEC88;
		}
	</style>
	
	
	<script>
	   
	   
		$(function(){
		    $('.dragR').draggable({
				proxy:'clone',
				revert:true,
				cursor:'auto',
				onStartDrag:function(){
					$(this).draggable('options').cursor='not-allowed';
					$(this).draggable('proxy').addClass('dp');
				},
				onStopDrag:function(){
					$(this).draggable('options').cursor='auto';
				}
			});
			$('.drag').draggable({
				proxy:'clone',
				revert:true,
				cursor:'auto',
				onStartDrag:function(){
					$(this).draggable('options').cursor='not-allowed';
					$(this).draggable('proxy').addClass('dp');
				},
				onStopDrag:function(){
					$(this).draggable('options').cursor='auto';
				}
			});
			$('.DivdropContainor').droppable({
				
				onDragEnter:function(e,source){
				
					$(source).draggable('options').cursor='auto';
					$(source).draggable('proxy').css('border','1px solid red');
					$(this).addClass('over');
				},
				onDragLeave:function(e,source){
				    
					$(source).draggable('options').cursor='not-allowed';
					$(source).draggable('proxy').css('border','1px solid #ccc');
					$(this).removeClass('over');
				},
				onDrop:function(e,source){
				    
				    document.getElementById('<%=HiddenID.ClientID %>').value = $(this).attr('id');
                    
                    document.getElementById('<%=HiddenProName.ClientID %>').value =$(source).find('p:first').text();
                    document.getElementById('<%=HiddenProRate.ClientID %>').value =$(source).find('p').text();
					__doPostBack('__Page', 'CmdGetProd');
					
				}
			});
			
		});
	</script>


Check following links for refferance


http://superdit.com/2011/04/02/drag-drop-shopping-cart-using-jquery/

http://www.placona.co.uk/166/javascript/a-more-elaborated-jquery-drag-drop-cloning/

http://davidwalsh.name/mootools-drag-ajax


http://www.jqwidgets.com/blog/


http://zfcms.blogspot.in/2011/07/simple-jquery-drag-and-drop-tutorials.html
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900