Wednesday, March 21, 2012

Define DropZones with DragOverlayExtender

Hi

I'm using the DragOverlayExtender to create a draggable UI (like live.com).
How can I define some fix drop-zones? So dragged objects should only drop there.

Tank you.

Hi,

I've just postedan article on my blog about drag&drop in Atlas, that includes an example of a draggable UI. Hope it helps.
Thx - this seems to be exactly what I was looking for!

But how can I add a control-section at runtime?

<control id="content1">
<behaviors>
<draggableListItem handle="content1Handle"
dataType="HTML" />
</behaviors>
</control>

I found that this works with

IScriptControl ctrl =
ScriptManager.GetCurrent(this).RegisterControl(myControl);

Then on ctrl there is a Method called RegisterBehaviour, but how can I use this. The method needs an IScriptBehavior-Implementation - so how can I use the draggableListItem-Behavior for this?
Hi,

Following the Atlas philosophy, the suggested approach (server-centric) would be that of creatingextenders for drop zones and draggable panels. Basically you have to derive a class fromExtenderControl and a class fromTargetControlProperties. Then, override theRenderScript() method of theExtenderControl class to render the Atlas markup.

Checkthis blog entry byNikhil Kotari orthis one from my Atlas blog, for some info about extenders.
Hi,

well, what I wrote above is not 100% correct, since anextender is supposed to extend an existing ASP.NET control or maybe acustom ASP.NET control. What you could do is build an Atlas-enabledserver control, rendering both the HTML and the Atlas markup.

Checkthis blog entry and look at the section "Support for Atlas-Enabled Server Controls" for some info.
Hey

So your second post is the way I tried... but I have still the problem that I mentioned. The number of controls that are draggable is not known at designtime, so I'd like to insert the DnD-behaviors for the different controls at runtime.

The follow method seems to be the one - but I don't know how to implement:
Microsoft.Web.Script.IScriptControl c =
ScriptManager.GetCurrent(this).RegisterControl(myControl);
c.RegisterBehavior(xxx);

So the 3x should be an IScriptBehavior-Implementation. In the declarative Way, I used
<control id="CVPart">
<behaviors>
<draggableListItem handle="CVPartTitle" dataType="HTML" />
</behaviors>
</control
So what do I have to do, to register this behavior (draggableListItem) at runtime.
OK... I found a quite simple solution... :-)

I've just created a new class that implements IScriptBehavior (and IScriptObject).
In the RenderScript-Method I just create the <draggableListItemhandle="myControl" type="HTML" /> with the ScriptTextWriter...

3 Lines of code... one day is over :-D
Thank you!

Hello! Could you please send me an example of your code?

Just to not waste the whole day for 3 lines of code ;)

Thank you!

No comments:

Post a Comment