ASP.NET Ajax Extender for multi-column widget drag & drop

My open source Ajax Start Page www.dropthings.com has an ASP.NET Ajax Extender which provides multi-column drag & drop for widgets. It allows reordering of widgets on the same column and also drag & drop between column. It also supports client side notification so that you can call web service and store the position of the widgets behind the scene without (async) postback.

I first thought of going for a plain vanilla Javascript based solution for drag & drop. It requires less code, less architectural complexity and provides better speed. Another reason was the high learning curve for making Extenders in proper way in Asp.net Ajax given that there’s hardly any documentation available on the web (during the time of writing this blog). However, writing a proper extender which pushes Asp.net Ajax to the limit is a very good way to learn under-the-hood secrets of Asp.net Ajax framework itself. So, the two extenders I will introduce here will tell you almost everything you need to know about Asp.net Ajax Extenders.

Ajax Control Toolkit comes with a DragPanel extender which I could use to provide drag & drop support to panels. It also has a ReorderList control which I could use to provide reordering of items in a single list. Widgets are basically panels that flow vertically in each column. So, it might be possible that I could create reorder list in each column and use the DragPanel to drag the widgets. But I could not use ReorderList because:

  • ReorderList strictly uses Html Table to render its items in a column. I have no table inside the columns. Only one Panel is there inside an UpdatePanel.
  • ReorderList takes a Drag Handle template and creates a drag handle for each item at runtime. I already have drag handle created inside a Widget which is the widget header. So, I cannot allow ReorderList to create another drag handle.
  • I need client side callback on drag & drop so that I can make Ajax calls and persist the widget positions. The callback must give me the Panel where the widget is dropped, which is dropped and at what position.

 

Next challenge is with the DragPanel extender. The default implement of Drag & Drop in Ajax Control Toolkit has some problems:

  • When you start dragging, the item becomes absolutely positioned, but when you drop it, it does not become static positioned. There's a small hack needed for restoring the original position to "static".
  • It does not put the dragging item on top of all items. As a result, when you start dragging, you see the item being dragged below other items which makes the drag get stuck especially when there's an IFRAME.

So, I have made a CustomDragDropExtender and a CustomFloatingExtender. CustomDragDropExtender is for the column containers where widgets are placed. It provides the reordering support. You can attach this extender to any Panel control.

Here's how you can attach this extender to any Panel and make that Panel support drag & drop of Widgets:  

   1: 
<
asp:Panel 
ID
="LeftPanel" 
runat
="server"  
class
="widget_holder" 
columnNo
="0"
>
   2:         
<
div 
id
="DropCue1" 
class
="widget_dropcue"
>
   3:         
</
div
>
   4: 
</
asp:Panel
>
   5:  
   6: 
<
cdd:CustomDragDropExtender 
ID
="CustomDragDropExtender1" 
   7:     
runat
="server" 
   8:     
TargetControlID
="LeftPanel"
   9:     
DragItemClass
="widget" 
  10:     
DragItemHandleClass
="widget_header" 
  11:     
DropCueID
="DropCue1"
  12:     
OnClientDrop
="onDrop" 
/>

<cdd:CustomDragDropExtender> offers the following properties:

  • TargetControlID – ID of the Panel which becomes the Drop zone
  • DragItemClass – All child elements inside the Panel having this class will become draggable. E.g. Widget DIV has this class so that it can become draggable.
  • DragItemHandleClass – Any child element having this class inside the draggable elements will become the drag handle for the draggable element. E.g. Widget Header area has this class, so it acts as the drag handle for the Widget.
  • DropCueID – ID of an element inside the Panel which acts as Drop Cue.
  • OnClientDrop – Name of a Javascript function which is called when widget is dropped on the Panel.

LeftPanel becomes a widget container which allows widgets to be dropped on it and reordered. The DragItemClass attribute on the extender defines the items which can be ordered. This prevents from non-widget Html Divs from getting ordered. Only the DIVs with the class "widget" are ordered. Say there are 5 DIVs with the class named "widget". It will allow reordering of only these five divs: 

   1: 
<
div 
id
="LeftPanel" 
class
="widget_holder" 
>
   2:         
<
div 
class
="widget"
> ... 
</
div
>
   3:         
<
div 
class
="widget"
> ... 
</
div
>
   4:  
   5:         
<
div 
class
="widget"
> ... 
</
div
>
   6:         
<
div 
class
="widget"
> ... 
</
div
>
   7:         
<
div 
class
="widget"
> ... 
</
div
>
   8:  
   9:         
<
div
>This DIV will not move
</
div
>
  10:         
<
div 
id
="DropCue1" 
class
="widget_dropcue"
></
div
>
  11: 
</
div
>

When a widget is dropped on the panel, the extender fires the function specified in OnClientDrop. It offers standard Ajax Events. But unlike basic Ajax events where you have to programmatically bind to events, you can define property and specify the function name to call. So, instead of doing this:

   1: 
function pageLoad( sender, e ) {
   2:  
   3:   
var extender1 =
$get(‘CustomDragDropExtender1’);
   4:   extender1.add_onDrop( onDrop );
   5:   
   6: }

You can do this:

   1: 
<
cdd:CustomDragDropExtender 
ID
="CustomDragDropExtender1" 
   2:     
runat
="server" 
   3:     
OnClientDrop
="onDrop" 
/>

When the event is raised, the function named onDrop gets fired. This is done with the help of some handy library available in ACT project.

When the event is fired, it sends the container, the widget and the position of the widget where the widget is dropped.

   1: 
function onDrop( sender, e )
   2: {
   3:     
var container = e.get_container();
   4:     
var item = e.get_droppedItem();
   5:     
var position = e.get_position();
   6:     
   7:     
//alert( String.format( "Container: {0}, Item:
{1}, Position: {2}", container.id, item.id, position ) );
   8:     
   9:     
var instanceId =
parseInt(item.getAttribute(
"InstanceId"));
  10:     
var columnNo =
parseInt(container.getAttribute(
"columnNo"));
  11:     
var row = position;
  12:     
  13:    
WidgetService.MoveWidgetInstance( instanceId, columnNo, row );
  14: }

 

The widget location is updated by calling the WidgetService.MoveWidgetInstance.

CustomDragDropExtender has 3 files:

  • CustomDragDropExtender.cs – The server side extender implementation
  • CustomDragDropDesigner.cs – Designer class for the extender
  • CustomDragDropExtender.js – Client side scriptfor the extender

Server side class CustomDragDropExtender.cs has the following code:

   1: [assembly:
System.Web.UI.WebResource(
"CustomDragDrop.CustomDragDropBehavior.js",

"text/javascript")]
   2:  
   3: 
namespace CustomDragDrop
   4: {
   5:     [Designer(
typeof(CustomDragDropDesigner))]
   6:     [ClientScriptResource(
"CustomDragDrop.CustomDragDropBehavior", 
"CustomDragDrop.CustomDragDropBehavior.js")]
   7:     [TargetControlType(
typeof(WebControl))]
   8:     [RequiredScript(
typeof(CustomFloatingBehaviorScript))]
   9:     [RequiredScript(
typeof(DragDropScripts))]
  10:     
public 
class CustomDragDropExtender :
ExtenderControlBase
  11:     {
  12:         
// TODO: Add your property accessors here.
  13:         
//
  14:         [ExtenderControlProperty]
  15:         
public 
string DragItemClass
  16:         {
  17:             get
  18:             {
  19:                 
return GetPropertyValue<String>(
"DragItemClass", 
string.Empty);
  20:             }
  21:             set
  22:             {
  23:                
SetPropertyValue<String>(
"DragItemClass", 
value);
  24:             }
  25:         }
  26:  
  27:         [ExtenderControlProperty]
  28:         
public 
string DragItemHandleClass
  29:         {
  30:             get
  31:             {
  32:                 
return GetPropertyValue<String>(
"DragItemHandleClass", 
string.Empty);
  33:             }
  34:             set
  35:             {
  36:                
SetPropertyValue<String>(
"DragItemHandleClass", 
value);
  37:             }
  38:         }
  39:  
  40:         [ExtenderControlProperty]
  41:         [IDReferenceProperty(
typeof(WebControl))]
  42:         
public 
string DropCueID
  43:         {
  44:             get
  45:             {
  46:                 
return GetPropertyValue<String>(
"DropCueID", 
string.Empty);
  47:             }
  48:             set
  49:             {
  50:                
SetPropertyValue<String>(
"DropCueID", 
value);
  51:             }
  52:         }
  53:  
  54:         [ExtenderControlProperty()]
  55:         [DefaultValue(
"")]
  56:         [ClientPropertyName(
"onDrop")]
  57:         
public 
string OnClientDrop
  58:         {
  59:             get
  60:             {
  61:                 
return GetPropertyValue<String>(
"OnClientDrop", 
string.Empty);
  62:             }
  63:             set
  64:             {
  65:                
SetPropertyValue<String>(
"OnClientDrop", 
value);
  66:             }
  67:         }
  68:  
  69:     }
  70: }

Most of the code in the extender defines the property. The important part is the declaration of the class:

   1: [assembly:
System.Web.UI.WebResource(
"CustomDragDrop.CustomDragDropBehavior.js",

"text/javascript")]
   2:  
   3: 
namespace CustomDragDrop
   4: {
   5:     [Designer(
typeof(CustomDragDropDesigner))]
   6:     [ClientScriptResource(
"CustomDragDrop.CustomDragDropBehavior", 
"CustomDragDrop.CustomDragDropBehavior.js")]
   7:     [TargetControlType(
typeof(WebControl))]
   8:     [RequiredScript(
typeof(CustomFloatingBehaviorScript))]
   9:     [RequiredScript(
typeof(DragDropScripts))]
  10:     
public 
class CustomDragDropExtender :
ExtenderControlBase
  11:     {

The extender class inherits from ExtenderControlBase defined in ACT project. This base class has additional features over Ajax runtime provided Extender base class. It allows you to define RequiredScript attribute, which makes sure all the required scripts are downloaded before the extender script is downloaded and initialized. This extender has dependency over another extender named CustomFloatingBehavior. It also depends on ACT’s DragDropManager. So, the RequiredScript attribute makes sure those are downloaded before this extender’s script is downloaded. The ExtenderControlBase is a pretty big class and does a lot of work for us. It contains default implementations for discovering all the script files for the extender and rendering them properly.

The [assembly:System.Web.UI.WebResource] attribute defines the script file containing the script for extender. The script file is an embedded resource file.

[ClientScriptResource] attribute defines the scripts required for the extender. This class is also defined in ACT. ExtenderControlBase uses this attribute to find out which .js files are working for the extender and renders them properly.

The challenge is to make the client side javascript for the extender. On the js file, there’s a Javascript pseudo class:

   1: Type.registerNamespace(
'CustomDragDrop');
   2:  
   3:
CustomDragDrop.CustomDragDropBehavior = 
function(element) {
   4:  
   5:    
CustomDragDrop.CustomDragDropBehavior.initializeBase(
this, [element]);
   6:     
   7:     
this._DragItemClassValue = 
null;    
   8:     
this._DragItemHandleClassValue = 
null;
   9:     
this._DropCueIDValue = 
null;
  10:     
this._dropCue = 
null;
  11:     
this._floatingBehaviors = [];
  12: }

During initialize, it hooks on the Panel it is attached to and the drop cue to show while drag & drop is going on over the Panel:

   1:
CustomDragDrop.CustomDragDropBehavior.prototype = {
   2:     
   3:     initialize : 
function() {
   4:         
// Register ourselves as a drop target.
   5:        
AjaxControlToolkit.DragDropManager.registerDropTarget(
this); 
   6:         
//Sys.Preview.UI.DragDropManager.registerDropTarget(this);
   7:         
   8:         
// Initialize drag behavior after a while
   9:         window.setTimeout(
Function.createDelegate( 
this, 
this._initializeDraggableItems ), 3000 );
  10:         
  11:         
this._dropCue = $get(
this.get_DropCueID());
  12:     },

After initializing the DragDropManager and marking the Panel as a drop target, it starts a timer to discover the dragable items inside the panel and create Floating behavior for them. Floating behavior is the one which makes a DIV draggable.

FloatingBehavior makes one DIV freely draggable on the page. But it does not offer drop functionality. DragDropBehavior offers the drop functionality which allows a freely moving DIV to rest on a fixed position.

Discovering and initializing floating behavior for the dragable items is the challenging work:

   1: 
// Find all items with the drag item class and
make each item
   2: 
// draggable        
   3: _initializeDraggableItems : 
function() 
   4: {
   5:     
this._clearFloatingBehaviors();
   6:     
   7:     
var el = 
this.get_element();
   8:     
   9:     
var child = el.firstChild;
  10:     
while( child != 
null )
  11:     {
  12:         
if( child.className == 
this._DragItemClassValue && child
!= 
this._dropCue)
  13:         {
  14:             
var handle = 
this._findChildByClass(child, 
this._DragItemHandleClassValue);
  15:             
if( handle )
  16:             {
  17:                 
var handleId = handle.id;
  18:                 
var behaviorId = child.id + 
"_WidgetFloatingBehavior";
  19:                 
  20:                 
// make the item draggable by adding floating
behaviour to it                    
  21:                 
var floatingBehavior =
$create(CustomDragDrop.CustomFloatingBehavior, 
  22:                         {
"DragHandleID":handleId, 
"id":behaviorId, 
"name": behaviorId}, {}, {}, child);
  23:                 
  24:                 Array.add( 
this._floatingBehaviors, floatingBehavior
);
  25:             }
  26:         }            
  27:         child = child.nextSibling;
  28:     }
  29: },

Here’s the algorithm:

  • Run through all immediate child elements of the control where the extender is attached to
  • If the child item has the class for draggable item, then:
    • Find any element under the child item which has the class for Drag handle
    • If such item found, then attach a CustomFloatingBehavior with the child item

The _findChildByClass function recursively iterates through all the child elements and looks for an element which has the defined class. It’s an expensive function. So, it is important that the drag handle is very close to the dragable element.

   1: _findChildByClass : 
function(item, className)
   2: {
   3:     
// First check all immediate child items
   4:     
var child = item.firstChild;
   5:     
while( child != 
null )
   6:     {
   7:         
if( child.className == className ) 
return child;
   8:         child = child.nextSibling;
   9:     }
  10:     
  11:     
// Not found, recursively check all child
items
  12:     child = item.firstChild;
  13:     
while( child != 
null )
  14:     {
  15:         
var found = 
this._findChildByClass( child, className
);
  16:         
if( found != 
null ) 
return found;
  17:         child = child.nextSibling;
  18:     }
  19: },

When user drags an item over the Panel where the extender is attached to, DragDropManager fires the following events:

   1: onDragEnterTarget : 
function(dragMode, type, data) {
   2:     
this._showDropCue(data);    
   3: },
   4:  
   5: onDragLeaveTarget : 
function(dragMode, type, data) {
   6:     
this._hideDropCue(data);
   7: },
   8:  
   9: onDragInTarget : 
function(dragMode, type, data) {
  10:     
this._repositionDropCue(data);
  11: },

Here we deal with the drop cue. The challenging work is to find out the right position for the drop cue.

We need to find out where we should show the drop cue based on where user is dragging the item. The idea is to find out the widget which is immediately below the dragged item. The item is pushed down by one position and the drop cue takes its place. While dragging, the position of the drag item can be found easily. Based on that, I locate the widget below the drag item:

   1: _findItemAt : 
function(x,y, item)
   2:     {
   3:         
var el = 
this.get_element();
   4:         
   5:         
var child = el.firstChild;
   6:         
while( child != 
null )
   7:         {
   8:             
if( child.className == 
this._DragItemClassValue && child
!= 
this._dropCue && child != item )
   9:             {
  10:                 
var pos =
Sys.UI.DomElement.getLocation(child);
  11:                 
  12:                 
if( y <= pos.y )
  13:                 {
  14:                     
return child;
  15:                 }
  16:             }
  17:             child =
child.nextSibling;
  18:         }
  19:         
  20:         
return 
null;
  21:     },

This function returns the widget which is immediately under the dragged item. Now I add the drop cue immediately above the widget:

   1: _repositionDropCue : 
function(data)
   2:     {
   3:         
var location =
Sys.UI.DomElement.getLocation(data.item);
   4:         
var nearestChild = 
this._findItemAt(location.x, location.y,
data.item);
   5:         
   6:         
var el = 
this.get_element();        
   7:             
   8:         
if( 
null == nearestChild )
   9:         {
  10:             
if( el.lastChild != 
this._dropCue )
  11:             {
  12:                 el.removeChild(
this._dropCue);
  13:                 el.appendChild(
this._dropCue);
  14:             }
  15:         }
  16:         
else
  17:         {
  18:             
if( nearestChild.previousSibling != 
this._dropCue )
  19:             {
  20:                 el.removeChild(
this._dropCue);
  21:                 el.insertBefore(
this._dropCue, nearestChild);            
  22:             }            
  23:         }
  24:     },

One exception to consider here is that there can be no widget immediately below the dragged item. It happens when user is trying to drop the widget at the bottom of column. In that case, the drop cue is shown at the bottom of the column.

When user releases the widget, it drops right on top of drop cue and the drop cue disappears. After the drop the onDrop event is raised to notify where the widget is dropped.

   1: _placeItem : 
function(data)
   2:     {
   3:         
var el = 
this.get_element();
   4:                 
   5:        
data.item.parentNode.removeChild( data.item );
   6:         el.insertBefore( data.item,

this._dropCue );
   7:         
   8:         
// Find the position of the dropped item
   9:         
var position = 0;
  10:         
var item = el.firstChild;
  11:         
while( item != data.item )
  12:         {  
  13:             
if( item.className == 
this._DragItemClassValue ) position++; 
  14:             item =
item.nextSibling; 
  15:         }
  16:         
this._raiseDropEvent( 
/* Container */ el, 
/* droped item */ data.item, 
/* position */ position );
  17:     }
 
Generally you can make events in extenders by adding two functions in the extender:
 
   1: add_onDrop : 
function(handler) {
   2:     
this.get_events().addHandler(
"onDrop", handler);
   3: },
   4:  
   5: remove_onDrop : 
function(handler) {
   6:     
this.get_events().removeHandler(
"onDrop", handler);
   7: },
 
But this does not give you the support for defining the event listener name in the ASP.NET declaration:
   1: 
<
cdd:CustomDragDropExtender 
ID
="CustomDragDropExtender1" 
   2:     
runat
="server" 
   3:     
OnClientDrop
="onDrop" 
/>

The declaration only allows properties. In order to support such declarative assignment of events, we need to first introduce a property named OnClientDrop in the extender. Then during assignment of the property, we need to find out the function specified there and attach event notification on that function. The discovery of the function from its name is done by CommonToolkitScripts.resolveFunction which is available in ACT project.

   1: 
// onDrop property maps to onDrop event
   2:     get_onDrop : 
function() {
   3:         
return 
this.get_events().getHandler(
"onDrop");
   4:     },
   5:  
   6:     set_onDrop : 
function(value) {
   7:         
if (value && (0 <
value.length)) {
   8:             
var func =
CommonToolkitScripts.resolveFunction(value);
   9:             
if (func) { 
  10:                 
this.add_onDrop(func);
  11:             } 
else {
  12:                 
throw Error.argumentType(
'value', 
typeof(value), 
'Function', 
'resize handler not a function, function name, or
function text.');
  13:             }
  14:         }
  15:     },
 
Raising the event is same as basic Ajax events:
 
 
   1: _raiseEvent : 
function( eventName, eventArgs ) {
   2:         
var handler = 
this.get_events().getHandler(eventName);
   3:         
if( handler ) {
   4:             
if( !eventArgs ) eventArgs =
Sys.EventArgs.Empty;
   5:             handler(
this, eventArgs);
   6:         }
   7:     },
 
This is all about the CustomDragDropExtender. Next challenge is to make the CustomFloatingBehavior. The server side class is declared as:
   1: [assembly:
System.Web.UI.WebResource(
"CustomDragDrop.CustomFloatingBehavior.js",

"text/javascript")]
   2:  
   3: 
namespace CustomDragDrop
   4: {
   5:     [Designer(
typeof(CustomFloatingBehaviorDesigner))]
   6:     [ClientScriptResource(
"CustomDragDrop.CustomFloatingBehavior", 
"CustomDragDrop.CustomFloatingBehavior.js")]
   7:     [TargetControlType(
typeof(WebControl))]
   8:     [RequiredScript(
typeof(DragDropScripts))]
   9:     
public 
class CustomFloatingBehaviorExtender :
ExtenderControlBase
  10:     {
  11:         [ExtenderControlProperty]
  12:         [IDReferenceProperty(
typeof(WebControl))]
  13:         
public 
string DragHandleID
  14:         {
  15:             get
  16:             {
  17:                 
return GetPropertyValue<String>(
"DragHandleID", 
string.Empty);
  18:             }
  19:             set
  20:             {
  21:                
SetPropertyValue<String>(
"DragHandleID", 
value);
  22:             }
  23:         }
  24:     }
  25: }

There’s only one property – DragHandleID. Widget’s header works as the drag handle. So, the header ID is specified here.

This extender has dependency on DragDropManager so the [RequiredScript(typeof(DragDropScripts))] attribute is there.

Besides the designer class, there’s one more class which CustomDragDropExtender need in order to specify its dependency over this floating behavior:

   1: [ClientScriptResource(
null, 
"CustomDragDrop.CustomFloatingBehavior.js")]
   2:   
public 
static 
class CustomFloatingBehaviorScript
   3:   {
   4:   }

This class can be used inside RequiredScript attribute. It only defines which script file contains the client side code for the extender.

The client side Javascript is same as FloatingBehavior that comes with ACT. The only difference is some hack when drag starts. DragDropManager does not return the item being dragged to static position once it makes it absolute. It also does not increase the zIndex of the item. If the drag item does not become the top most item, while dragging it goes below other elements on the page. So, I have made some changes in the mouseDownHandler of the behavior to add these features:

   1: 
function mouseDownHandler(ev) {
   2:     window._event = ev;
   3:     
var el = 
this.get_element();
   4:     
   5:     
if (!
this.checkCanDrag(ev.target)) 
return;
   6:     
   7:     
// Get the location before making the element
absolute
   8:     _location =
Sys.UI.DomElement.getLocation(el);
   9:  
  10:     
// Make the element absolute 
  11:     el.style.width = el.offsetWidth
+ 
"px";
  12:     el.style.height =
el.offsetHeight + 
"px";            
  13:    
Sys.UI.DomElement.setLocation(el, _location.x, _location.y);       
       
  14:     
  15:     _dragStartLocation =
Sys.UI.DomElement.getLocation(el);        
  16:     
  17:     ev.preventDefault();
  18:     
  19:     
this.startDragDrop(el);
  20:     
  21:     
// Hack for restoring position to static
  22:     el.originalPosition = 
"static";
  23:     el.originalZIndex =
el.style.zIndex;
  24:     el.style.zIndex = 
"60000";
  25: }

Setting el.originalPosition = static fixes the bug in DragDropManager. It incorrectly stores absolute has the originalPosition when startDragDrop is called. So, after calling this function, I set it to correct originalPosition which is “static”.

When drag completes, the original zIndex is restored and left, top, width and height is cleared. DragDropManager makes the item position static, but it does not clear the left, top, width and height attributes. This moves the element away from the place where it is dropped. This bug is fixed in the onDragEnd event:

   1: 
this.onDragEnd = 
function(canceled) {
   2:     
if (!canceled) {
   3:         
var handler = 
this.get_events().getHandler(
'move');
   4:         
if(handler) {
   5:             
var cancelArgs = 
new Sys.CancelEventArgs();
   6:             handler(
this, cancelArgs);
   7:             canceled =
cancelArgs.get_cancel();
   8:         }            
   9:     }
  10:     
  11:     
var el = 
this.get_element();
  12:     el.style.width =
el.style.height = el.style.left = el.style.top = 
"";
  13:     el.style.zIndex =
el.originalZIndex;
  14: }

That's all folks!

You can get the code for the extenders here.

Published Thu, Mar 22 2007 21:03 by omar
Filed under:

Comments

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, March 23, 2007 3:58 AM by Boris

Hi Omar,

excellent post!

Thank you very much!

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, March 23, 2007 8:50 AM by Geoff

Hey Omar,

 Long time fan and user of page flakes. I am curious when you first started writing your widgets did you look at web parts and why did you decide to not use them? Thanks,

     G

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, March 24, 2007 12:10 AM by omar

I looked at Web parts end of 2005. As far as I remember, it was quite inflexible and I was not able to make a quick prototype of Pageflakes out of it easily. Moreover, we require 95% of the features to be on client side with Javascript. So, we need a framework which facilitates that. WebParts only gives a very small part of it like Drag & Drop. I also did not find way to get notification of drag & drop on client side and instead of a postback, how to call web service to transmit the data. Besides the multipage feature at the client side is something not supported in Web parts.

In a summary, Pageflakes requires too much facility on the client side which Web parts don't offer. Although web parts is a very nice framework for most of the common need to personalization UI, but not for Ajax Start Pages which are extreme implementation of Rich Internet Application.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, March 30, 2007 4:19 AM by alexeypajitnov@hotmail.com

the drag and drog doesn't work with ASP.NET AJAX V1.0 and AjaxToolkit 1.0.10301.0?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, March 31, 2007 11:20 AM by Andy

Please answer the previous question- I followed the instructions as closely as I could, in AJAX v1.0, and my panels are not being rearranged. I get an odd behavior (but some behavior) with the floating panel extender, but at least it does something. controls inside of a control extended with the CustomDragDropExtender seem to exhibit no behavior at all.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, April 02, 2007 10:40 PM by marshallbu

I was able to get this example working with latest AJAX v1.0 and the latest toolkit.  One problem I was experiencing though, is an infinite javascript loop when I drop a "widget" outside of either column.  It seems to be happening in the "getScrollOffset" function somewhere in the toolkit.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, April 11, 2007 9:30 PM by Luke

Hi Omar - once again, fantastic post. I am getting an error when trying to add CustomFloatingBehavior to each of the widgets in the _initializeDraggableItems function.

It's causing an exception which states that 'type' (ie CustomDragDrop.CustomFloatingBehavior) does not derive from Sys.Component.

Just not sure why it would be doing this - is this an indication that it just can find the script file or could it be something else? The script file is in the same class lib as CustomDragDropBehavior.js and it makes it into this fine.

Any ideas?

Cheers

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, April 11, 2007 9:56 PM by Luke

By the way. add a FloatingBehavior extender by itself does not produce the error, only when you attempt to add floatingbehavior to each widget via the customdragdrop script does it fail.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Sunday, April 29, 2007 8:02 AM by AJ

Hi Omar,

Would just like to commend you on your post here and your tutorial on codeproject.com.  I find your posts extremely informative and am definately going to bookmark your blog and check up on it from time to time.

A question I have for you though is whether or not all these Microsoft tools are worth it.  As I'm sure you've seen, these tools are often times buggy or close to what you want, but unable to do what you exactly want.  This results in countless hours of hacky fixes or overriding of code.  Is it really worth it when you can just find open source tools that's faster and works just as well?

The only problem I see with using open source tools is that sometimes they have problems adapting to ie, which microsoft tools program for.  I really get torn on this issue.  I can't tell you how many times I've used microsoft tools only having regretted getting so far into it and finding out that some controls just don't work well with other controls.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, April 30, 2007 2:52 PM by Raj

Hello Omar,

I am getting the follwing runtime error when using the CustomDragDropExtender in CustomFloatingBehavior.js file.

Can you give me any pointers on where the problem could.

Error: 'AjaxControlToolkit undefined'

location:

At

CustomDragDrop.CustomFloatingBehavior.registerClass('CustomDragDrop.CustomFloatingBehavior',

//Sys.UI.Behavior,

//Sys.Preview.UI.IDragSource,

AjaxControlToolkit.BehaviorBase,

AjaxControlToolkit.IDragSource,

Sys.IDisposable);

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, April 30, 2007 9:02 PM by omar

Look like AjaxControlToolkit is missing. Please download and install latest Ajax Control Toolkit.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, May 01, 2007 8:39 AM by Raj

Omar,

Thank you for the reply.  Actually the AjaxControltoolkit is present.  I can work with the other extenders that come with ACT, no problem.

Strangely, I can make your extender work if I use Sys.UI and Sys.Preview instead of AjaxControlTookit.*

Any ideas.  It must be something small becasue if I use Sys.* instead of AjaxControlToolkit.* everything stars working.  I know I can go with Sys.* but perfrmance is important for me as you pointed out in the next post.

Thanks in advance

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, May 05, 2007 11:35 PM by omar

I found this bug. Seems like it has started recently. The problem is my CustomDragDrop extender uses AjaxControlToolkit. Although AjaxControlToolkit is mentioned as required script, but it is not getting initialized before my extender does. But if you use any of the AjaxControlTookit extenders before my CustomDragDrop Extender gets loaded, it works fine.

One example is put a hidden button the page before any of the declaration of CustomDragDrop extender and attach a ConfirmButtonExtender to it.

<asp:Button ID="dummy" runat="server" />

   <ajaxToolkit:ConfirmButtonExtender TargetControlID="dummy" runat="server" ConfirmText="Are you sure you want to do this?" />

This will force AjaxControlToolkit to load and initialize before my extender does.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, May 05, 2007 11:41 PM by omar

Hi AJ,

The problem you mentioned with components not working on all environments is common to both Microsoft and Open Source components. None of them can develop components which serve all specific needs of everyone. They target solving 70-90% scenario. But there are always exceptional scenario when things don't work out of the box. We cannot expect another company or another developer be able to solve my own problems all the time. I will always have to tweak things and make it work as I want. Good thing about open source is I can do that. But with closed source MS components, I can't do that.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, May 14, 2007 10:33 AM by Shahar Nechmad

Hi Omar.

Really great post. Thanks for all your time and work you had to put in order to share that with us.

I'm trying to download your code from the link in the bottom of the article, but the link seems to be broken.

Could you please post it again?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, May 21, 2007 7:52 PM by Amit

Hi omar,

Could you please give me an example on how to use all th eabove cool stuff in asps page?

Thanks

Amit

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, May 21, 2007 11:21 PM by omar

Hi Amit,

The beginning of the post shows how to put this extender on an ASPX page and make DIVs drag and drop enabled.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, May 22, 2007 7:30 PM by Abram

Any chance a sample Database can come with the code. I might be missing something, is the DB generated if not available.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, May 26, 2007 5:26 AM by Prem

Hi Omar

I m not able to use this extender.

I m getting javascript error "CustomDragDrop" is undefined.

What to do?

Plz Help it is very urgent.........

Thanks

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, May 26, 2007 7:26 AM by Christian

Hi Omar,

great post. So i want to start with it and try to implement, but I'm getting the following javascript error: Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter name: interfaceTypes[0] Source File: localhost/.../ScriptResource.axd

Line: 687

I'm using the AjaxControlToolkit file (1.0.61214) from your download. First I had the same error like Raj, but with your help i could fix it and got now the error above :-/

Christian

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, May 26, 2007 7:29 AM by Christian

@Prem

Do you have a link to CustomDragDrop Project in your Webapplication and at the WebForm a linkstatement like these: <%@ Register Assembly="CustomDragDrop" Namespace="CustomDragDrop" TagPrefix="cdd" %>?

Christian

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, May 31, 2007 4:27 AM by Raj Nair

Hello Omar,

I'm also getting same error as christain. Any fixes recently?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, May 31, 2007 4:38 AM by Christian

I got it :-). The important thing was that i had forgot options in scriptmanager. First i start with default once:

<asp:ScriptManager ID="ScriptManager1" runat="server" />

But i got an error (previous comment). So debug a lot in javascript, but nothing. So after hours i start to compare the code line by line... And so you have the following options:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" LoadScriptsBeforeUI="false" ScriptMode="Release" />

After i append these in my code, it runs perfect... ;-)

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, May 31, 2007 5:03 AM by raj nair

Hi Christain,

If you dont mind can u upload a small working sample somewhere. Though I'm not getting any errors now, extender is not working as expcted.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, May 31, 2007 7:26 AM by Christian

Hi Raj,

i try to post some code and a link to a zip file (test project), but it doesn't work. So i publish my comment and a link on my own <a href="www.steinisweb.de/.../a>

Hope it helps.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, May 31, 2007 7:37 AM by Christian

Oups, html doesn't work. So here is the link again www.steinisweb.de/.../PermaLink,guid,a15eefc7-27ea-46b3-8541-791ab9483838.aspx

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, June 11, 2007 2:47 AM by Mike

Anyone else get this to work?  If so can you upload an example, I tried Christian's above but that only seems to have 1 column with 1 widget box and I can't seem to add anymore without having undesired effects.  so anyone else have an example??

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, June 13, 2007 10:09 AM by Daniel

May i suggest a little "correction" in CustomDragDropBehavior.js?

The _showDropCue() function does a weird behaviour with the cue's div height. This another version of the code fix for me that behaviour:

from:

<code>

_showDropCue : function(data)

   {

       this._repositionDropCue(data);

       this._dropCue.style.display = "block";

       this._dropCue.style.visibility = "visible";

       var bounds = Sys.UI.DomElement.getBounds(data.item);

       if( this._dropCue.style.height == "" )

           this._dropCue.style.height = bounds.height.toString() + "px";

   },

</code>

to:

<code>

_showDropCue : function(data)

   {

var bounds = Sys.UI.DomElement.getBounds(data.item);

       this._dropCue.style.height = bounds.height.toString() + "px";

       this._repositionDropCue(data);

       this._dropCue.style.display = "block";

       this._dropCue.style.visibility = "visible";

   },

</code>

I first calculate the cue's div height and assign it (always) before show it.

Daniel.

Thanks for your great piece of code, Omar. I hope MS take it as example.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Sunday, June 17, 2007 2:25 PM by Amit

Very good post!!

Need some help from you in customizing this...I want items not to snap to columns and stick to the screen where I drop them. Also to store the location, I want to store the location (x,y,z coordiantes) and not column and order!!

What is the easiest way to achieve this? Please help.

Regards

Amit

# AJAX Fight Night at Web 2.0 &#038; White Wall Wisdom

Tuesday, June 19, 2007 8:10 AM by AJAX Fight Night at Web 2.0 & White Wall Wisdom

Pingback from  AJAX Fight Night at  Web 2.0 &#038; White Wall Wisdom

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, June 26, 2007 6:30 AM by Packman

I am getting  'this._activeDragVisual is null or undefined error'. Could antbody can help me.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, June 29, 2007 7:16 AM by stone

Hello Omar,

I have bilud your open source success, but I am getting the follwing error when clicking pagetab linkbutton or new tab linkbutton on my dropthings website

Can you give me any pointers on where the problem could.

Error: "Value of member 'CurrentPageId' of an object of type 'UserSetting' changed,A member defining the identity of the object cannot be changed. Consider adding a new object with new identity and deleting the existing one instead."

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, June 29, 2007 7:21 AM by stone

Hello Omar,

I have bilud your open source success on Visual Studio Orcas, but I am getting the follwing error when clicking 'My First Page/My 2nd Page' linkbutton or 'new tab' linkbutton on my dropthings website,

Can you give me any help on where the problem could.

Error: "Value of member 'CurrentPageId' of an object of type 'UserSetting' changed,A member defining the identity of the object cannot be changed. Consider adding a new object with new identity and deleting the existing one instead."

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, June 30, 2007 9:35 AM by omar

Please turn off CurrentPageId as primary key from database. You will see a composite key in UserSetting.

Will you be interested to share the Orcas version with the community? Please email me the code if you are interested.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, June 30, 2007 2:45 PM by stone

Hi Omar

Thank you for the reply.

I have sent mail to you. attachment is the Orcas version source

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, June 30, 2007 2:50 PM by stone

Hi Omar

  Thank you for the reply.I have send the Orcas version Dashboard source to you by email.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Sunday, July 01, 2007 12:53 AM by Greg

You have any thoughts on what would be the best way to store a user's settings as they drag and drop widgets on their "page" so that others see the changes when they navigate to that page? (i'm thinking in terms of a very slimmed down portal) -- Would it be writing the coordinates to a database for each widget/div?

thanks,

-g

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, July 02, 2007 5:08 AM by Packman

I am getting  'this._activeDragVisual is null or not an object' error. Could antbody can help me.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, July 05, 2007 2:27 AM by stone

Hi Omar

  I'm getting the same error,How can I turn off CurrentPageId as primary key from database.

  follwing changes is correct?

"

USE [Dashboard]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[UserSetting](

[UserId] [uniqueidentifier] NOT NULL,

[CurrentPageId] [int] NOT NULL,

CONSTRAINT [PK_UserSetting] PRIMARY KEY CLUSTERED

(

[UserId] ASC,

[CurrentPageId] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[UserSetting]  WITH CHECK ADD  CONSTRAINT [FK_UserSetting_aspnet_Users] FOREIGN KEY([UserId])

REFERENCES [dbo].[aspnet_Users] ([UserId])

GO

ALTER TABLE [dbo].[UserSetting] CHECK CONSTRAINT [FK_UserSetting_aspnet_Users]"

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, July 05, 2007 10:01 AM by Packman

Though i register the custom CustomDragDrop contol in my page i still get the error 'CustomDragDrop' is 'undifined' while deploying in Win2003 server.

But it work fine on when i deployed it on my development server(XP).

How can i deploy it on Win2003 server.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, July 05, 2007 11:41 AM by stone

on Win2003 server?

My CustomDragDrop work fine on win2003 except "CurrentPageId cann't be changed".  you may rebuild CustomDragDrop with AjaxControlToolkit(version:1.0.10618.0)

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, July 12, 2007 2:57 PM by bhavesh

same Error: "Value of member 'CurrentPageId' of an object of type 'UserSetting' changed,A member defining the identity of the object cannot be changed. Consider adding a new object with new identity and deleting the existing one instead."

hey stone!! did the above query worked for you?? I tried, it didnt work for me.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, July 13, 2007 6:28 AM by stone

I do not know how to remove the primary key.

As you said, in the UserSetting table,CurrentPageID is already NOT assigned as primary key. If it is already not assigned as primary key then how one can remove primary key from that field?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, July 16, 2007 5:28 PM by Sat

Omar, Your Blog is too lengthy, I think, you need to make steps, so that developers can able to understand, I tried almost every thing possible, I got results no more than standard Ajax controls, but thanks for your efforts though and lengthy theory.

Good luck for your next Blog and we are waiting for you.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, July 23, 2007 9:13 AM by Hemen

Hi Omar,

its nice work for widget. i have used ur DLL for my application. but i have one problem. when there are more then 3 widgets vertically, i have to scroll down to catch header of widget after 3 levels. so in that case when i click on header, whole widget body is moves up by the amount i have scroll down. so my cursor is not on widget body in this case. some times it moves upward so much that i cant even see the widget. so will u please tell me what and where changes r required. so my widget remains at where my mouse pointer.

Thanx a lot,

Regards,

Hemen.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, July 24, 2007 7:00 AM by Packman

Thanx stone.

Its works 4 me.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, July 25, 2007 12:32 AM by Hemen

Plz any body can help me in solve out my problem. i hav post my prob on 23rd july. i repeat it here.

when there are more then 3 widgets vertically, i have to scroll down to catch header of widget after 3 levels. so in that case when i click on header, whole widget body is moves up by the amount i have scroll down. so my cursor is not on widget body in this case. some times it moves upward so much that i cant even see the widget. so will u please tell me what and where changes r required. so my widget remains at where my mouse pointer.

Thanx a Lot.

Regards,

Hemen.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, July 26, 2007 5:27 AM by M.

I've recently made a lib of my own based on what i've read here. The only problems I have right now are the scroll bug (which seems to be the problem not only here, but also on pageflakes, igoogle etc.) and the AjaxControlToolkit initialization. Does anyone know how to solve the second problem? I would like to freely use my lib without being forced to put invisible items on my page just to initialize the toolkit.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, July 26, 2007 8:24 AM by Hemen

Plz any body can help me in solve out my problem. i hav post my prob on 23rd july. i repeat it here.

when there are more then 3 widgets vertically, i have to scroll down to catch header of widget after 3 levels. so in that case when i click on header, whole widget body is moves up by the amount i have scroll down. so my cursor is not on widget body in this case. some times it moves upward so much that i cant even see the widget. so will u please tell me what and where changes r required. so my widget remains at where my mouse pointer.

Thanx a Lot.

Regards,

Hemen.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, July 31, 2007 9:16 AM by Hemen

Hello Everybody,

i have resolve the problem which i have posted previously. but there is one more problem, with repeater control.when i use Repeater control in widget and try to show more then 3 items(more then 3 columns) in repeater control, then it load data perfectly. but when i try to drag it, it will close the explorer.

if any body has idea regarding this problem then let me know.

Thanx,

Regards,

Hemen.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, July 31, 2007 9:16 AM by Sean

Is it possible to make a panel a drop zone with a working drop cue at run at run time?

Basically I would like to fire up the initialize thats performed on a panel when it has an extender attached to it... but I will need to do this on a panel created at some point in the pages life.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, July 31, 2007 6:43 PM by Sean

M. its wierd, because I don't have that problem at all. I can just put the extender, a panel, a scriptmanager and some divs with the correct classes on the page.

Its seems the scrolling "bug" is universal though on all the sites I've seen with drag and drop.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 02, 2007 5:13 AM by cip

Hi Omar,

The extender works fine for me, only very slow when moving widgets in IE 7. I noticed it's not slow on dropthings.com, any idea why this is happening ?

Thanks

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, August 06, 2007 9:02 AM by Amin J. Ismaili

Hi,

I am developing one website using ASP.NET 2.0 and AJAX Toolkit 1.0

First I would be more then happy if you can email me a solution in ASP.NET 2.0 because on your website the solution is available in ASP.NET 3.0

I am able to configure the extender to work perfectly, but when I hit refresh it goes back to where it was, I mean the drag-drop changes are lost. I am just hitting F5.

I saw dropthings.com and tried refreshing it, but it doesn't have that problem.

Can you help me with this regard?

Waiting...

Amin Ismaili

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 16, 2007 1:28 AM by Kaushik

Hello,

Can you give me this code in asp.net using vb language ?

my email is kaushik132002@yahoo.com

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 16, 2007 1:28 AM by Kaushik

Hello,

Can you give me this code in asp.net using vb language ?

my email is kaushik132002@yahoo.com

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, August 21, 2007 9:33 AM by PJ

Awesome control.  I was able to get it up and running pretty easily in my solution.  I am having one problem though that I didn't see addressed previously.  After dragging an item from one panel to another, I start to get the following javascript error on mouse move

Error: element has no properties

Source File: localhost/ScriptResource.axd

Line: 633

This is using firefox.  In IE, I get a different error:

Line: 556

Error: 'this._activeDragVisual' is null or not an object

Not sure what is causing the problem.  Any help would be greatly appreciated.

Thanks,

-PJ

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 30, 2007 3:35 AM by TingeltangelBob

Hi Omar,

Awesome extender!!! I successfully managed to get the example running in no time. -> Thank you very much.

However, as I try to add a Drag Drop-Item dynamically, I also receive the error in IE:

'this._activeDragVisual' is null or not an object

Can anyone help? The line is 565, at Char 9.

Here is my OnInit-Routine (the rest is the reduced example on :

protected override void OnInit(EventArgs e)

   {

       base.OnInit(e);

       //LeftPanel finden

       Panel LeftPanel = (Panel)Page.FindControl("LeftPanel");

       Panel widget = new Panel();

       widget.ID = "dynamicWidget";

       widget.CssClass = "widget";

       widget.Attributes.Add("runat", "server");

       Panel widgetHeader = new Panel();

       widgetHeader.ID = "dynamicWidgetHeader";

       widgetHeader.CssClass = "widget_header";

       widgetHeader.Attributes.Add("runat", "server");

       Label label = new Label();

       label.Text = "Dynamic Widget";

       widgetHeader.Controls.Add(label);

       widget.Controls.Add(widgetHeader);

       LeftPanel.Controls.Add(widget);

       CustomDragDropExtender extender = new CustomDragDropExtender();

       extender.ID = "dynamicCustomDragDropExtender";

       extender.TargetControlID = "LeftPanel";

       extender.DragItemClass = "widget";

       extender.DragItemHandleClass = "widget_header";

       extender.DropCueID = "DropCue1";

       extender.OnClientDrop = "onDrop";

       LeftPanel.Controls.Add(extender);

   }

This is the only change I made to the reduced example (except for adding my AjaxControlToolKit and updating the CustomDragDrop Extender with it).

I'm using the Ajax 1.0 and Ajax ControlToolKit 1.0.61214.0. In Mozilla, everything works nicely.

Any help is apprecated.

Best,

Tingeltangel

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 30, 2007 3:36 AM by TingeltangelBob

I forgot to mention, that the error only appears, as I try to drag and drop the dynamically created Item.

Best,

Tingeltangel

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 30, 2007 4:01 AM by TingeltangelBob

Stupid me, I have identified my error:

Just delete the last lines:

     CustomDragDropExtender extender = new CustomDragDropExtender();

      extender.ID = "dynamicCustomDragDropExtender";

      extender.TargetControlID = "LeftPanel";

      extender.DragItemClass = "widget";

      extender.DragItemHandleClass = "widget_header";

      extender.DropCueID = "DropCue1";

      extender.OnClientDrop = "onDrop";

      LeftPanel.Controls.Add(extender);

and everything works. Maybe this can help for the others to identify the same error.

Best,

Tingeltangel

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 30, 2007 10:40 AM by Shahriat Somel

Hi Omar vai,

 I just want to know the list of server controls and client controls which are compatible to the particular Ajax Extender.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 30, 2007 10:00 PM by Korn

Hi Omar,

How can you make a horizontal implementation for drag and drop..? Meaning instead of creating left, middle and right panel, I would be creating 3 or more panels vertically, thus the position of the widgets will be arrange horizontally and not vertically (by rows not by column) hope you understand my post..

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 30, 2007 10:05 PM by Korn

Hi Omar,

One for question for dropthings... Is it hard to implement for dropthings wherein UI for the widgets are loaded first, after that, the process takes place? Thanks...

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 30, 2007 10:13 PM by Korn

One more comment on the drag and drop for dropthings is when you drag the topmost widget and position it in the 2nd row on the same column, the changes will not be reflected... (by pressing F5) Thanks...

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 30, 2007 10:17 PM by Korn

posted by cip..

Hi Omar,

The extender works fine for me, only very slow when moving widgets in IE 7. I noticed it's not slow on dropthings.com, any idea why this is happening ?

Thanks

Hi cip,

Have you checked your web.config if the debug=false?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, August 30, 2007 11:12 PM by omar

Hi Korn,

For delayed widget loading, try this approach:

www.codeproject.com/.../DelayedContentLoading.asp

Regarding slow performance, please use debug="false" in <compilation> node in web.config.

Or change the mode of ScriptManager to "Release". The debugging scripts are really slow.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, August 31, 2007 12:15 AM by Korn

Thanks Omar... I will look into the topic and see if I can apply it in your dropthings... I've been working on you dropthings project for almost 4 months already... but I'm using these widgets to display management content... Learned a lot from your project... but still there's  alot to learn coz I'm still a newbie.. and one more thing.. I'm a great fan of yours..

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, September 12, 2007 1:23 PM by Harkrishan

Hi Omar

Nice technology demonstration. I have tried to run the code provided, but i am getting the following javascript error

this._dropTarget is null or not an object.

Can you please help me in getting rid of this error.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, September 12, 2007 1:40 PM by Harkrishan

Hi

Does somebody share with me the working copy of the project. Please mail me at harkrishan@gmail.com

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, September 12, 2007 1:40 PM by Harkrishan

Hi

Can somebody share with me the working copy of the project. Please mail me at harkrishan@gmail.com

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, September 19, 2007 7:10 AM by Iyad Marzouka

I am also getting this javascript error sometimes.

this._dropTarget is null or not an object.

Is there a solution to this problem?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, September 19, 2007 12:38 PM by Anders Josefsson

I have the same problem as the two above.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, September 20, 2007 1:45 AM by Iyad Marzouka

It seems to appear if you start draging the widgets directly after the page loads. But if you wait about 3 seconds after the page loads this error wont appear.

Any ideas?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, September 20, 2007 4:10 AM by Iyad Marzouka

I have noticed a 3000 ms delay in the CustomDragDropBehavior.js file line 25. It waits 3 seconds before initializing the draggable widgets.

window.setTimeout( Function.createDelegate( this, this._initializeDraggableItems ), 3000 );

When you try to drag a widget before they are initialized you will notice the javascript error above (this._dropTarget is null or not an object).

I am not sure why this delay is set to high. I reduced it to 100 ms and now it works fine.

Omar, first I would like to thank you for this amazing contribution. Can you please tell me what is the reason behind this delay?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, September 20, 2007 4:33 AM by omar

When there're lots of widgets on the page, creating Drag handler for each of them takes some time and IE 6 gets stuck for a while. If I do this during load while widgets are loading their content and UI updates are going on, IE 6 freezes for a while.

So, it was deferred to 3 sec. Assumption is users will not start dragging widgets so soon.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, October 08, 2007 1:18 AM by NNM

it looks interesting but youor page http://www.dropthings.com/ has java errors...

Flicker... is undefined...

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, October 11, 2007 9:59 AM by Surjit Singh Dadhwal

Hi Omar,

This is a very very helpful post.

I want to save the locaion of the dropped items and then want to show them at same location (where it was dropped earlier) after the user visits the page in future (until changed again).

As the widgets are saved at the respective locations in igoogle also.

Please help me, how can i do this.

Thanks

Surjit Dadhwal

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, October 12, 2007 6:07 PM by wyx2000

Right, you dropthing site has several JS errors.

And the sample on www.steinisweb.de/.../PermaLink,guid,a15eefc7-27ea-46b3-8541-791ab9483838.aspx

is not very helpful.

I think sample is helping people to understand, that sample is too simple to demo the feature.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, October 12, 2007 6:11 PM by wyx2000

Another thing. Did you test it by putting it into a usercontrol, I got this when I do that:

Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter name:interfaceTypes[0]

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Sunday, October 14, 2007 12:17 AM by omar

I will upload VS 2008 compatible code soon which solves most of the problems.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, October 18, 2007 5:17 PM by Aeries

Omar,

thank you for the effort in doing this for all of us.

I still can't get it to run. I downloaded your source code and build it. Drop the dll into my website bin folder and regsiter the assembly on the page where i will use it, including the Ajaxcontroltoolkit dll.

Was able to run the page without error, but it's a blank page. I added some text between the div. Nothing show up. Copied and paste www.steinisweb.de sample and run it. It comes up with Widget Title. try to drag it, nothing happen.

Any other sample would be appreciated.

Aeries

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, October 19, 2007 3:33 PM by Aeries

Okay,

my bad, www.steinisweb.de sample does work. you  have to wait a few second before you can drag and drop. I think it's 3 second because Omar set it in his js file.

Thanks Omar ... your work is awasome =) ...

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, October 23, 2007 4:33 AM by HejtmaMa

Hi Guys, especially Omar

Great code, just few notes, I spent about one afternoon figuring out the issues and somehow I feel responsible to tell everyone to save the others from same stress with debugging :-)

First, some minor changes:

1) You should always change the height of the cue area, otherwise its size is set only once and does not apply to the second and next containers you drag and drop:

       var h = bounds.height;

       if (h <= 0)

       {

           h = 5;

       }

       var newheight = h.toString() + "px";

       if ( this._dropCue.style.height != newheight )

       {

           this._dropCue.style.height = newheight;

       }

2) window.setTimeout( Function.createDelegate( this, this._initializeDraggableItems ), 3000 );

I think 3 seconds is too long, the page seems not to work when you drag immediately or even causes JS errors, it should be shorter or based on some page event (load maybe?). Haven't got the time to check this yet.

3) This one gave me a hard time figuring out. Question is "How to create the extender independent on some 'dummy' extender which includes the scripts necessary?" I spent a lot of time trying to figure out what I have to include to the source file to allow the extended to be standalone, here's my solution for it:

[RequiredScript(typeof(CommonToolkitScripts))]

[RequiredScript(typeof(TimerScript))]

[RequiredScript(typeof(FloatingBehaviorScript))]

[RequiredScript(typeof(DragDropScripts))]

[RequiredScript(typeof(DragPanelExtender))]

And YES!, it works without additional 'dummy' toolkit components on the page.

Please note that the order of the scripts matters.

So finally, thanks Omar for his great work and hopefully my post will be useful for you.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, October 24, 2007 3:04 PM by Marcus

How would one go about implementing something like a Fantasy Hockey predraft?  For example I'd want a database driven list of players on one side and a blank panel on the other where I could drag the players from the left to the right panel and then reorder them in the right panel by dragging as desired.  Is that possible with this control?  How would I set it up?  

I was playing with this thing for a little while and it seems I would need a separate "Extender" and Panel for each player. Is that right?

I actually need it for picking columns used in a user created dynamic database query, but I thought the Fantasy Hockey draft was a better example :)

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, October 26, 2007 1:25 PM by Aeries

HejtmaMa:

base on your javascript, where do i put it? Is it in CustomDragDropBehavior.js file at line 222? Can you show us your modification? Thanks you.

To all;

base on Omar's code above with his

<div id="leftPanel" ...>

 <div id="widget" ...>

 <div id="widget" ...>

 <div id="widget" ...>

 <div id="widget" ...>

on my code: i have the <asp:panel id="leftpanel" runat="server">, which is

static on the aspx page, and the widgets are created at runtime. my problem is, when i create a panel at runtime and add it to the LeftPanel. It works, but i cannot move that panel (widget).

therefore, i have to create the widget panels static. Like Omar has up there. Is there an attribute that I have to set to the panel at runtime to be able to have the same functionality? thanks all.

Aeries

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, October 26, 2007 1:42 PM by Aeries

HejtmaMa:

Nice, it works. I also set the width of the dropCue as well.

Question: my dropCue has a border, when the page first load, the dropCue is visible until you click a widget then it disappears.

do you know how to set the dropCue not visible when the page first loaded? thanks.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, November 03, 2007 2:32 AM by Vikas Sharma

Hi Thanks for such a good post .

I want to know as to how we can set the positions and store them in our database.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, November 19, 2007 8:16 AM by Stan

Hi,

Newbie question, how can I install the code source ?

Any help ?

Stan

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, November 21, 2007 5:16 AM by Ravindra

Hello omar,

I have the related question,

I worked with AJAX in my web project.I need "to select(drag) one table data and drop it on another table" using AJAX(TABLES are GridViews). At the same time I wanted assigned value will be change in BOTH the tables and related DATABASE also.

Eg:Table1-(Its an Total number of available hours for Workers.)

Name-- workhours

xyz -- 8 --> I wanted to drag this coloumn to table2.And Assign work 2hrs to this name.

abc -- 8

pqr -- 8

Table2-(Its an Assign list for workers to works only 2hours each.)

Name -- Assigned Hrs

xyz -- 2 --> I draged this form table1.At this time I wanted changes in table1 with xyz-->6 hrs & remains same.

If any one know this concept or any ajax Toolkit supports this concept plz reply.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, November 22, 2007 7:51 AM by Lee Timmins

Hi HejtmaMa, how did you get this to work without the dummy control.  I tried changing the top of my CustomDragDropExtender.cs file to:

[Designer(typeof(CustomDragDropDesigner))]

   [ClientScriptResource("CustomDragDrop.CustomDragDropBehavior", "CustomDragDrop.CustomDragDropBehavior.js")]

   [TargetControlType(typeof(WebControl))]

   [RequiredScript(typeof(CommonToolkitScripts))]

   [RequiredScript(typeof(TimerScript))]

   [RequiredScript(typeof(FloatingBehaviorScript))]

   [RequiredScript(typeof(DragDropScripts))]

   [RequiredScript(typeof(DragPanelExtender))]

but i had no joy.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, November 27, 2007 5:48 PM by M.

To anybody who might want to build a similar webpage: If you still have a choice, choose something different than ASP.NET :)

ASP.NET combined with ASP.NET AJAX is a real pain in the ass. Try adding to the dropthings project some advanced controls which use viewstate. You'll surely encounter a problem with restoring the viewstate when you move the widget to a different column. This happens because viewstate is saved for the whole control tree and is restored from the root to the leaves which makes it impossible to restore when being loaded to a panel different than the original upon a postback.

# Drag and Drop functionality / support for ASP.NET AJAX.

Tuesday, December 04, 2007 1:07 PM by ASP.NET AJAX Forum Posts

I&#39;d like to create some custom Drag &amp; Drop functionality through Client side ASP.NET AJAX APIs

# Drag and Drop functionality / support for ASP.NET AJAX. &laquo; .NET Framework tips

Pingback from  Drag and Drop functionality / support for ASP.NET AJAX. &laquo; .NET Framework tips

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, December 07, 2007 1:37 AM by michelia

@ Aeries.

please add some atribute to the drop cube's css class:

display:none;

visibility:hidden;

the dropcube won't appear when the page first loaded.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, December 07, 2007 1:46 AM by michelia

I meet a problem, i have three columns.

left  : no any widgets

middle: has widget

right : ...

it appear an error:

"

Error: System.ArgumentException: does not derive from Sys.Component.

Parameter name:type

Code: 0

"

*if the first column has least one widget. this problem's no found.

please !!!

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Sunday, December 09, 2007 5:42 AM by Davide Vernole

Great post!

You demostrated the power of the extender.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, December 13, 2007 8:19 AM by aswad32

hi omar thanks for the control toolkit, i'm currently doing a project with that extender under asp.net 2.0, it working just fine. thank you for saving my time and my life.. this is great man

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, December 17, 2007 5:24 AM by HejtmaMa

Hi guys, sorry for late response,

Aeries:

You can set display: none or height: 0px to hide the cue by default, that should be just enough

Lee Timmins: This is the start of my updated code and it was enough to make it work without dummy control:

using System;

using System.Web.UI.WebControls;

using System.Web.UI;

using System.ComponentModel;

using System.ComponentModel.Design;

using AjaxControlToolkit;

using AjaxControlToolkit.Design;

[assembly: WebResource("CMS.ExtendedControls.DragAndDropBehavior.js", "text/javascript")]

namespace CMS.ExtendedControls

{

   /// <summary>

   /// Drag and drop extender class

   /// </summary>

   [Designer(typeof(DragAndDropDesigner))]

   [ClientScriptResource("CMSExtendedControls.DragAndDropBehavior", "CMS.ExtendedControls.DragAndDropBehavior.js")]

   [TargetControlType(typeof(WebControl))]

   [RequiredScript(typeof(CommonToolkitScripts))]

   [RequiredScript(typeof(TimerScript))]

   [RequiredScript(typeof(FloatingBehaviorScript))]

   [RequiredScript(typeof(DragDropScripts))]

   [RequiredScript(typeof(DragPanelExtender))]

   public class DragAndDropExtender : ExtenderControlBase

   {

...

At the moment, I am facing little more difficulties. When I drag the element and it causes the body height to change (it is on the bottom of the web page), the location of the element does not match the cursor location and it is kind of difficult to place the element to the zones. Did anyone face this issue and managed to solve it in some simple way?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, January 07, 2008 2:55 PM by dan

Omar, is your extender working in ASP.NET? Thanks

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, January 08, 2008 10:09 PM by tipsieq

can you please send me code for dropthings.com using .net 2.0 instead of 3.0 at tipsieq@gmail.com

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, January 09, 2008 5:39 PM by skaoth

Are there any restrictions regarding code usage or licensing? I working on a project and would like to use this functionality. Just want to make sure

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, January 10, 2008 7:04 AM by Siddharth

I am working in direction to move control place in a gridview like your page www.dropthings.com and i like your post very much ,but not implemented it successfully on asp.net 2.0 please provide me the code of that functionality.

I hope you help me.

Thanks

Siddharth

Sid.gyanvihar@gmail.com

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, January 15, 2008 7:17 AM by HejtmaMa

Hi guys, me again

Enough to fix for "this._dropTarget is null" error is to add onmousemove="return false" to the content (not to the handle). This disables the floating (or maybe DragDrop) behavior for the content which is not draggable

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, January 16, 2008 7:01 PM by Raymon

Hello Omar. I´m venezuelan. Congratulations for your work. A have read how to implement CustomsDragDrop, to use the widgetcontainer but a I  have had some troubles, because the CustomsDragDrop.dll file don´t work with the latest version of AjaxControlToolKit 1.0.10618.0. I would be grateful for you, if you can send me the CustomsDragDrop.dll to work with this version of Ajax.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, January 21, 2008 12:11 AM by Vikash

Hi omar,

I just want some of the widget can not move

is this possible ? if so then pls provide sample code by which i can turn off the drag drop of some specific widgets.

Thanks,

Vikash

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, February 29, 2008 12:09 PM by David Jones

You don't say how to incorporate this into an existing VB.NET web site. So far I am not finding any way to use this code.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Saturday, March 08, 2008 1:18 AM by suresh

Hi Omar,

I have seen your dropthing.com i am really excited i am using your source for tesing i am getting few problems.when i drag and drop a widget, i could see only the header but not the actual widget. If i click on the widget header then it showing the full widget.Here the widget content is a chart(infragistics).

I tryed in one way in the javascript function onDrop()

i placed the alert()and then i am running the appliction means drag and drop after displys the alert box the widget not getting minimize it showing on the screen.if there is no alert the widget getting close.

function onDrop( sender, e )

{

   var container = e.get_container();

   var item = e.get_droppedItem();

   var position = e.get_position();

   //alert( String.format( "Container: {0}, Item: {1}, Position: {2}", container.id, item.id, position ) );

   var instanceId = parseInt(item.getAttribute("InstanceId"));

   var columnNo = parseInt(container.getAttribute("columnNo"));

   var row = position;

   WidgetService.MoveWidgetInstance( instanceId, columnNo, row );

   alert('End');

   }

Your help in this regard is highly appreciated.

Regards

Suresh K

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, March 12, 2008 11:56 AM by Marco

Hi Homar,

thanks for sharing such as great piece of code. I am trying to make it work on .net 2.0 framework can you kindly send the code to a-side@hotmail.it

Regards,

Marco

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, March 31, 2008 6:31 AM by Andrej

When Target control is absolutely positioned I am getting 2 issues;

1) Element's position is not same as mouse position

2) I am able to drop widget only bellow the existing widget but not abowe

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, April 02, 2008 7:12 AM by kalyan

omar first of all i thank u for such a great piece of work and i'm trying to implement ur code in my project but i'm getting few errors .

So please send me the code of ur dropthing.com to my mail id coz i'm want the same thing in my project.

Plz send it to beekalyan@gmail.com

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, April 08, 2008 11:00 PM by Sai

Hello Omar,

I think this is a excellent piece of work and I have currently built a web portal, which we call it a dashboard to display metrics/data from multiple products. We did initally in ASP.NET 2.0 and web parts, it was working great but had issues with postback on drag and drop of gadgets. We recently migrated to ASP.NET 3.5 which has fixed the issue with page post-back by using update panel. But that didnt resolve the issue because on drag and drop its not full page postback but still a server round trip and gadget will load the data again, which is a performance hog. For my situation do you think your solution is better or stick with web parts? Appreciate your feedback.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, April 09, 2008 4:51 PM by David Jones

I AM STILL TRYING TO GET THIS TO WORK IN IE. DOESN'T ANYONE NOTICE THE PANELS WON'T DRAG IN IE?? IS THE DEVELOPER STILL ALIVE??

I GENERATE EVERYTHING IN VB.NET, IT WORKS PERFECT IN FF, NOT AT ALL IN IE!!!!!!!!!

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, April 16, 2008 1:15 PM by Karel

Maybe a stupid question, but how can I get the "close" button in the upper right corner to close (read: hide) the panel ... I tried an image an fire an onclick JavaScript that hides the widget div. This works, but only as long as I don't move the widgets, since as soon as I start moving a widget, it won't react to the "close" button anymore. It looks like the onclick is handled by the widget header only which makes the widgets handle the click as a move action. Strangely enough, mouseover, mouseout, etc. works fine for the close button. Any ideas?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, April 21, 2008 12:36 AM by Dhina

Hi Omar,

You done a great job, Thanks lot.. I have my existing web application which is developed in ASP.NET 3.5 and SQL Server2000. I want to use dropthings code in my web application, But i dnt know how to do it, Please explain more about how to add drag and drop functional alone in my existing site, and explain more about profile provider in web.config file.. Please can u send me the details regarding this to my mail ID, dhinaharan.thangaraj@g-antssoft.com

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, April 24, 2008 10:31 PM by Sandeep Tanwer

hi all

i was gatting this error

'this._activeDragVisual' is null or not an object

for model popup. actually i was trying popup model inside a model popup.

just remove  PopupDragHandleControlID and enjoy

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, May 02, 2008 8:55 AM by Karl

Hi Omar,

your code is amazing!! But I still have a question regarding the prerequisites: I use VS 2005 with AJAX Control Toolkit. Could I use the code or do I need ASP.net 3.5 and VS 2008? On CodeProject you mention .net 2.0 and .net 3.5, on Codeplex it seems to be VS 2008 and in your blog here you said (14. Oct 2007) you want to upload 2008 code (= currently it's for 2005).

Thanks!

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, May 08, 2008 8:09 AM by Tarek Yehia

I found solution to scrolled problem bug (which seems to be the problem not only here, but also on pageflakes, igoogle etc.) It needs from us do small fix in MicrosoftAjax.js. I wrote article describe my Fix:

webapplication02.blogspot.com/.../ajax-getlocation-problem.html

This code work with Ajax 1.0 --> Ajax 3.5

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, May 20, 2008 2:11 AM by Loïs

Hi,

I want to use your extender for a website but I don't know how can I use it. When I add a reference (with project tab), I can't use it. How can I do, please ?

Thank you.

Ps : sorry for possible language errors, I'm not very good in english.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, May 28, 2008 6:25 AM by Manoj

Hi Omar

I m not able to use this extender.

I m getting javascript error "CustomDragDrop" is undefined.

What to do?

Plz Help it is very urgent.........

--

Manoj

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, June 11, 2008 7:46 PM by Fernando

Hi Omar,

Thanks a lot for this great job!!!

I'm trying to use some of this code on my own project but i'm getting some problems...

i get this error:

Could not load file or assembly 'CustomDragDrop' or one of its dependencies. The system cannot find the file specified.

in the code i have this:

<%@ Register Assembly="CustomDragDrop" Namespace="CustomDragDrop" TagPrefix="cdd" %>

and i have the folder with the js files...

i don't now where the problem is!

Thank you.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, July 08, 2008 10:13 AM by jo

I followed exactly your instruction but until now I cannot get this to work. When the page is loaded,  a client script error comes up saying that OnDrop is undefined.

Please help.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, July 08, 2008 10:32 AM by omar

Jo,

On your page, you need to define a functon named onDrop.

function onDrop()

{

}

The extender tries to access this function because you told the extender to call this function whenever a drag & drop happens.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, July 08, 2008 10:58 AM by jo

Pardon me Omar. I'm a novice asp.net developer.

In your example, WidgetService.MoveWidgetInstance is being called. Do I have to create this service myself? How?

I don't mean to sound unappreciative but normally, when I find an extender, I add it on my toolbox, drag it to my form, set its properties and it works. As a user of your extender, do we need anything else (e.g. OnDrop) to make it to work?

I appreicate your help. I think this is great. I just need to learn exactly how to set it up.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, July 25, 2008 2:27 AM by vidhya

Hi omar,

I downloaded the source code.. but i unable to run that.. the file doesnt contain any aspx page.. have only cs file js file..i am using asp.net ajax 3.5.. can u plz help me... plz send me the working example to my mail id.. it is vidhya@ilink-systems.com

# msmvps.com christian

Sunday, August 24, 2008 8:22 PM by christian

Let me begin by saying  that i love your blog msmvps.com a lot

now.. back  to the post haha

I cant say that im 100% with what you typed up... care to clear things up for me?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, August 25, 2008 7:55 AM by Kanedogg

vidhya: firstly you should learn to read the tutorial first, secondly if you had some idea about coding you'd already have worked out it appears to be a class/extender. so there wont be an aspx page. Dude it's constructive critasizm, you'll figure this all out after a few good asp2/ajax books try some "Sams" or "O'rilley" titles!

Omar: keep up the good works man i'm a big fan of your stuff, its defiantely not for Noobs as i had asked you a similar question as vidhya about 1 year ago and didnt even get a response !! *frowns* -- feed your followers man we make who you are!

Cheers

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, August 25, 2008 8:14 AM by omar

Hi Christian,

this is an advanced topic, so a bit hard to grasp. If you have some specific areas that you don't understand, let me know. I will try to clear it up.

Sorry Vidhya for not getting back to you earlier. I don't always get notification on comment posts.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, September 15, 2008 3:16 PM by JohnM

Hi Omar,

Thank you for your post.  I am trying to get the CustomDragDrop extender to work, but I must be missing something.

Where do I put the CS and JS files that are included in the source code?  Do I have to compile them?  If so, do I put the DLL in Bin when done?

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Sunday, November 16, 2008 11:37 AM by Osama

Hi Omar,

you are not just the MVP but ur the King

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, November 21, 2008 8:56 AM by Ted

OK, so I downloaded your code and compiled it (after remarking out the following line from CustomDragDropExtender.cs - [RequiredScript(typeof(FloatingBehaviorScript))], as this line was causing a compilation error) with version 1.0.20229.20821 of the AjaxControlToolkit. I used example aspx page from Mike Puddephat and also included the 2 .js files in it. I have referenced the compiled .dll in my project. This is what I have codewise for my aspx page:

<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<%@ Register Assembly="CustomDragDrop" Namespace="CustomDragDrop" TagPrefix="cdd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "www.w3.org/.../xhtml11.dtd">

<html xmlns="www.w3.org/.../xhtml">

<head id="Head1" runat="server">

<title>ASP.NET AJAX Extender for multicolumn drag & drop</title>

<style type="text/css">

.rightcol { width: 30%; float: left; padding: 0.5em; border: 1px solid black; margin: 0.5em; }

.leftcol { width: 30%; float: left; padding: 0.5em; border: 1px solid black; margin: 0.5em; }

.widget_header { width: 100%; padding-top: 0.1em; padding-bottom: 0.1em; margin: 0em; font-size: 100%; font-weight: normal; cursor: move; background-color: #f0f0f0; }

.widget { position: relative; left: 0px; top: 0px; margin-bottom: 1em; background-color: white; }

.widget_dropcue { border: dashed 1px gray; display:none; margin-bottom: 1em; }

</style>

</head>

<body>

<script language="javascript" src="CustomDragDropBehavior.js" type="text/javascript" />

<script language="javascript" src="CustomFloatingBehavior.js" type="text/javascript" />

<script language="javascript" type="text/javascript">

function onDrop(sender, e)

{

var container = e.get_container();

var item = e.get_droppedItem();

var position = e.get_position();

var columnNo = parseInt(container.getAttribute("columnNo"));

alert( String.format( "Container: {0}, Item: {1}, Position: {2}, Column: {3}", container.id, item.id, position, columnNo ) );

}

</script>

<form id="form1" runat="server">

   <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"

       LoadScriptsBeforeUI="false" ScriptMode="Release" />

   <div>

   <asp:Button ID="dummy" runat="server" />

  <cc1:ConfirmButtonExtender TargetControlID="dummy" runat="server" ConfirmText="Are you sure you want to do this?" />

       <asp:Panel ID="_leftPanel" runat="server" columnNo="0" CssClass="leftcol">

           <div class="widget" id="widget_1">

               <div class="widget_header" id="widget_header_1" runat="server">

               Widget Header 1

               </div>

           </div>

           <div class="widget" id="widget_2">

               <div class="widget_header" id="widget_header_2" runat="server">

               Widget Header 2

               </div>

           </div>

           <div id="drop_cue_left" class="widget_dropcue">

           </div>

       </asp:Panel>

       <cdd:CustomDragDropExtender ID="_customDragDropExtenderLeft" runat="server" TargetControlID="_leftPanel"

           DragItemClass="widget" DragItemHandleClass="widget_header" DropCueID="drop_cue_left"

           OnClientDrop="onDrop" />

       <asp:Panel ID="_rightPanel" runat="server" columnNo="1" CssClass="rightcol">

           <div class="widget" id="widget_3">

               <div class="widget_header" id="widget_header_3" runat="server">

               Widget Header 3

               </div>

           </div>

           <div class="widget" id="widget_4">

               <div class="widget_header" id="widget_header_4" runat="server">

               Widget Header 4

               </div>

           </div>

           <div id="drop_cue_right" class="widget_dropcue">

           </div>

       </asp:Panel>

       <cdd:CustomDragDropExtender ID="_customDragDropExtenderRight" runat="server" TargetControlID="_rightPanel"

           DragItemClass="widget" DragItemHandleClass="widget_header" DropCueID="drop_cue_right"

           OnClientDrop="onDrop" />

   </div>

</form>

</body>

</html>

As you can see I have added the 'dummy' button and confirm button extender (which functions properly) that should activate the AjaxControlToolkit as suggested in one of your responses. However, it is still not working. I am using MS VS Pro 2005. The page loads and I get the 'crosshairs' indicating that I should be able to move the 'widget' but all that happens is the text highlights. Nothing moves, no dropcue appears. I get the following 2 errors on the page:

1) Line: 5

Char: 1

Error: 'Type' is undefined

Code: 0

URL: localhost/.../Default.aspx

2) Line: 258

Char: 20

Error: 'onDrop' is undefined

Code: 0

URL: localhost/.../Default.aspx

Any thoughts as to what I might be doing wrong?

Thanx in advance!

Ted

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, November 21, 2008 10:02 AM by Ted

I found my error. I had put the 'onDrop' function in the body and not the head of the page. All is working now - but it does require the 'dummy' button and confirmbuttonextender to run.

Ted

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, November 21, 2008 12:25 PM by Ted

Omar,

How do you keep the new placement of the widgets on page refresh? Whenever I refresh/postback the widgets return to their starting positions.

Thanx in advance,

Ted

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Tuesday, December 02, 2008 10:57 AM by BigFish

Hi Omar

I m not able to use this extender.

I m getting javascript error "CustomDragDrop" is undefined.

What to do?

Plz Help it is very urgent.........

# Deleting a simple item(widget)

Thursday, December 11, 2008 3:29 AM by Anak1n

Hi everyone, before i ask my question, i would like to say that this work is totally impressive so congratulations !

Configuration : .Net 2.0 - VS2005

My problem is that i have two simple zones where there is 2 items(widgets) in each.

I would like to had a button on each item to simple remove them from the dragable zone.

The buttons i would like to affect an action are named "BtnDelete..". How can i code a function to remove them ?

Here is my code :

------------------ CODE -------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Second.aspx.cs" Inherits="Second" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "www.w3.org/.../xhtml11.dtd">

<html xmlns="www.w3.org/.../xhtml">

<head id="Head1" runat="server">

   <title>Drag and Drop Test</title>

   <style type="text/css">

.rightcol { width: 300px; float: left; padding: 0.5em; border: 1px solid black; margin: 0.5em; }

.leftcol { width: 300px; float: left; padding: 0.5em; border: 1px solid black; margin: 0.5em;  }

.widget_header { width:auto; padding-top: 0.1em; padding-bottom: 0.1em; margin: 0em; font-size: small; cursor: move; background-color: #f0f0f0; font-family:Arial;}

.widget { position: relative; left: 0px; top: 0px; margin-bottom: 0.4em; background-color: white; }

.widget_dropcue { border: dashed 1px red; display:none; margin-bottom: 1em; }

</style>

</head>

<body>

   <form id="form1" runat="server">

       <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"

           LoadScriptsBeforeUI="false" ScriptMode="Release" />

       <div>

           <asp:Panel ID="_leftPanel" runat="server" columnNo="0" CssClass="leftcol">

               <div class="widget" id="widget_1">

                   <div class="widget_header" id="widget_header_1" runat="server">

                       Widget Header 1

                       <asp:Button ID="BtnDelete1" runat="server" Text="remove item" />

                   </div>

               </div>

               <div class="widget" id="widget_2">

                   <div class="widget_header" id="widget_header_2" runat="server">

                       Widget Header 2

                       <asp:Button ID="BtnDelete2" runat="server" Text="remove item" />

                   </div>

               </div>

               <div id="drop_cue_left" class="widget_dropcue">

               </div>

           </asp:Panel>

           <cdd:CustomDragDropExtender ID="_customDragDropExtenderLeft" runat="server" TargetControlID="_leftPanel"

               DragItemClass="widget" DragItemHandleClass="widget_header" DropCueID="drop_cue_left"

               OnClientDrop="onDrop" />

           <asp:Panel ID="_rightPanel" runat="server" columnNo="1" CssClass="rightcol">

               <div class="widget" id="widget_3">

                   <div class="widget_header" id="widget_header_3" runat="server">

                       Widget Header 3

                       <asp:Button ID="BtnDelete3" runat="server" Text="remove item" />

                   </div>

               </div>

               <div class="widget" id="widget_4">

                   <div class="widget_header" id="widget_header_4" runat="server">

                       Widget Header 4

                       <asp:Button ID="BtnDelete4" runat="server" Text="remove item" />

                   </div>

               </div>

               <div id="drop_cue_right" class="widget_dropcue">

               </div>

           </asp:Panel>

           <cdd:CustomDragDropExtender ID="_customDragDropExtenderRight" runat="server" TargetControlID="_rightPanel"

               DragItemClass="widget" DragItemHandleClass="widget_header" DropCueID="drop_cue_right"

               OnClientDrop="onDrop" />

       </div>

   </form>

   <script type="text/javascript">

function onDrop(sender,e)

{

   var container = e.get_container();

   var item = e.get_droppedItem();

   var position = e.get_position();

   var instanceId = parseInt(item.getAttribute("InstanceId"));

   var columnNo = parseInt(container.getAttribute("columnNo"));

   var row = position;

   try

   {

       WidgetService.MoveWidgetInstance(instanceId, columnNo,row );

   }

   catch(e)

   {

   }

}

   </script>

</body>

</html>

------------------ CODE -------------------

Thanks you for your help :)

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Thursday, December 11, 2008 12:51 PM by Nithi Gurusamy

Following line from CustomDragDropExtender.cs is giving compiler error. Is it safe to remove this line?

[RequiredScript(typeof(FloatingBehaviorScript))]

Error 2 The type or namespace name 'FloatingBehaviorScript' could not be found (are you missing a using directive or an assembly reference?) C:\NithiGurusamy\Projects\AdvisoryConsole\CustomDragDrop\CustomDragDropExtender.cs 21 25 CustomDragDrop

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, March 20, 2009 5:57 AM by chirag

Hi Omar,

Thank you for your post.  I am trying to get the CustomDragDrop extender to work, but I must be missing something.

Where do I put the CS and JS files that are included in the source code?  Do I have to compile them?  If so, do I put the DLL in Bin when done?

I m getting javascript error "CustomDragDrop" is undefined.

What to do?

Plz Help it is very urgent.........

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Friday, March 20, 2009 8:27 AM by chirag

hi guys,

I am getting javascript error onDrop is undefined.

Plz help?

Thanks

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, March 25, 2009 7:24 AM by swapnil ekhe

I am using the Customdragdrop extender it works fine with firefox ..but in ms internet explorer I am not able to select the header of widget properly, the selected widget goes to upperside and drops into another div also it is moving anywhere on my dashboard page ... Please help me to sole it.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, June 08, 2009 9:30 AM by rasedo

Hi, i'm trying to use this drag drop extender, but i'm rendering mi panels in a listview,  Extender for multi-column widget drag & drop works in a listview????? plz help

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, June 08, 2009 9:33 AM by rasedo

when i use Extender for multi-column widget drag & drop in a  list i get this:

The TargetControlID of 'CustomDragDropExtender1' is not valid. A control with ID 'thePanelID' could not be found.

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Monday, June 08, 2009 9:45 AM by tochoni

i'm getting: Error Creating Control - CustomDragDropExtender2Unable to cast object of type 'Netco.CustomExtenders.CustomDragDrop.CustomDragDropDesigner' to type 'System.ComponentModel.Design.IDesigner'.

What i'm missing???

# http://business.goodnano-av.com/

Thursday, July 02, 2009 6:57 PM by crerielem

Read more hot reports about Business, Form business or Women small business loans business.goodnano-av.com

# re: ASP.NET Ajax Extender for multi-column widget drag & drop

Wednesday, January 06, 2010 3:19 AM by santosh.achanta@logica.com

Hi Omar,

This is a very very helpful post.

I want to save the locaion of the dropped items and then want to show them at same location (where it was dropped earlier) after the user visits the page in future (until changed again).

As the widgets are saved at the respective locations in igoogle also.

Please help me, how can i do this.

Leave a Comment

(required) 
(required) 
(optional)
(required)