<%@ Control Language="c#" AutoEventWireup="True" Codebehind="DropOtherControl.ascx.cs" Inherits="ASPNETExpert.WebControls.Demo.Tree.Advanced.DropOtherControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register TagPrefix="ecd" Namespace="ASPNETExpert.WebControls.DemoControls" Assembly="ASPNETExpert.WebControls.DemoControls" %>
<%@ Register TagPrefix="ec" Namespace="ASPNETExpert.WebControls" Assembly="ASPNETExpert.WebControls" %>
<script language="javascript">
function AfterDropHandler(dragnDrop) {
if(dragnDrop.GetTargetNode() && confirm('Move ' + dragnDrop.GetSourceNodes()[0].Text + ' To ' + dragnDrop.GetTargetNode().Text + '?'))
dragnDrop.ClientNodeMove();
else
if(dragnDrop.GetTargetElement()) {
if(dragnDrop.GetTargetDropId() == 'Image' && dragnDrop.GetSourceNodes()[0].Value != null)
dragnDrop.GetTargetElement().src = 'images/fauna/' + dragnDrop.GetSourceNodes()[0].Value;
if(dragnDrop.GetTargetDropId() == 'Text')
dragnDrop.GetTargetElement().value = dragnDrop.GetSourceNodes()[0].Text;
if(dragnDrop.GetTargetDropId() == 'ListBox')
dragnDrop.GetTargetElement().options[dragnDrop.GetTargetElement().length] = new Option(dragnDrop.GetSourceNodes()[0].Text);
}
}
</script>
<table cellSpacing="0" cellPadding="0" border="0" xmlns:ec="urn:http://aspnetexpert.com/ExpertControls.xsd">
<tr>
<td valign=top>
<ec:ExpertTree id="DropOntoControlTree" runat="server" DragAndDropEnabled="true" Drop="ScriptResolved">
<OnClientAfter NodeDropHandler="AfterDropHandler" />
<TreeLook Width="220" Height="300px" Overflow="Scroll" />
<Looks>
<ec:TreeNodeLook Runat="server" Id="Parent1" BindStrategy="AutoBind">
<InitLook>
<ExpandButton Width="11px" Height="11px" ImageResourceUrl="XP.ExpandButton.gif" />
<NodeIcon Width="16px" Height="16px" Padding-Left="3px" Padding-Right="3px" />
<TextSection ForeColor="Black" Font-Name="Tahoma,Verdana,Arial" Font-Size="12px" Padding-Top="2px" Padding-Left="5px" Padding-Bottom="2px" Padding-Right="5px" Cursor="Default" />
</InitLook>
<HoveredLook>
<TextSection ForeColor="#000066" Font-Name="Tahoma,Verdana,Arial" Font-Size="12px" Font-Decoration="Underline" />
</HoveredLook>
<ExpandedLook>
<ExpandButton Width="11px" Height="11px" ImageResourceUrl="XP.CollapseButton.gif" />
</ExpandedLook>
<SelectedLook>
<TextSection ForeColor="White" Background-Color="#2060C0" Padding-Top="1px" Padding-Left="4px" Padding-Bottom="1px" Padding-Right="4px" Border-Style="Dotted" Border-Color="#CE953A" Border-Width="1px" />
</SelectedLook>
<SelectedHoveredLook>
<TextSection ForeColor="White" Background-Color="#2060C0" Padding-Top="1px" Padding-Left="4px" Padding-Bottom="1px" Padding-Right="4px" Border-Style="Dotted" Border-Color="#CE953A" Border-Width="1px" Font-Name="Tahoma,Verdana,Arial" Font-Size="12px" Font-Decoration="Underline" />
</SelectedHoveredLook>
<DisabledLook>
<TextSection ForeColor="#808080" />
</DisabledLook>
<SubTree>
<Expand Effect="GlideTopToBottom" Duration="100" />
<Collapse Effect="GlideTopToBottom" Duration="100" />
</SubTree>
</ec:TreeNodeLook>
</Looks>
<Nodes>
<ec:TreeNode Expanded="true" Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/Desktop.gif" Text="Desktop">
<Nodes>
<ec:TreeNode Expanded="true" Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/MyDocuments.gif" Text="My Documents">
<Nodes>
<ec:TreeNode Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/MyPictures.gif" Text="My Pictures" Expanded="true">
<Nodes>
<ec:TreeNode Text="Cat" Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/MyPictures.gif" Value="cats.jpg" />
<ec:TreeNode Text="Tiger" Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/MyPictures.gif" Value="tiger.jpg" />
<ec:TreeNode Text="Lion" Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/MyPictures.gif" Value="lions.jpg" />
<ec:TreeNode Text="Butterfly" Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/MyPictures.gif" Value="butterfly.jpg" />
</Nodes>
</ec:TreeNode>
<ec:TreeNode Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/MyMusic.gif" Text="My Music" />
</Nodes>
</ec:TreeNode>
<ec:TreeNode Expanded="true" Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/MyComputer.gif" Text="My Computer">
<Nodes>
<ec:TreeNode Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/FloppyDrive.gif" Text="31/2 Floppy (A:)" />
<ec:TreeNode Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/LocalDrive.gif" Text="Local Disk (C:)" />
<ec:TreeNode Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/LocalDrive.gif" Text="New Volume (D:)" />
</Nodes>
</ec:TreeNode>
<ec:TreeNode Look-InitLook-NodeIcon-ImageUrl="../images/Explorer/RecycleBin.gif" Text="Recycle Bin (Not Draggable)" IsDraggable="false" />
</Nodes>
</ec:TreeNode>
</Nodes>
</ec:ExpertTree>
</td>
<td style="PADDING-LEFT: 30px" vAlign="top">
<table cellSpacing="0" cellPadding="0" border="0">
<tr>
<td><p>Drag and drop nodes onto a control / HTML element below.</p></td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="3" border="0" width="100%" height="120">
<tr>
<td valign="top"><input type="text" runat="server" id="Text1" DropId="Text"></td>
<td valign="top"><asp:ListBox Runat="server" ID="ListBox1" DropId="ListBox" CssClass="DropListBox"></asp:ListBox></td>
<td valign="top"><img src="images/fauna/cats.jpg" border="0" DropId="Image"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="DragAndDropEnabled" Runat=server CssClass="formtext" Text="Enable Drag-and-Drop" Checked=True AutoPostBack=True oncheckedchanged="DragAndDropEnabled_CheckedChanged"></asp:CheckBox>
</td>
</tr>
<tr>
<td style="PADDING-TOP: 10px"><span class="formtext">DropAction</span>
</td>
</tr>
<tr>
<td><asp:radiobuttonlist id="DropActionList" CellSpacing="0" CellPadding="2" Font-Size="8" Font-Names="Verdana, Tahoma, Arial"
RepeatDirection="Vertical" AutoPostBack="True" Runat="server" onselectedindexchanged="DropActionList_SelectedIndexChanged">
<asp:ListItem Value="AutoPostBack">AutoPostBack</asp:ListItem>
<asp:ListItem Selected="True" Value="ScriptResolved">Script Resolved</asp:ListItem>
</asp:radiobuttonlist></td>
</tr>
<tr>
<td valign=top style="PADDING-LEFT:10px">
<ecd:DescriptionView runat="server" ID="Descriptionview1">
<ecd:Description id="Description1" runat="server">
You can drop nodes onto a Web control / plain HTML element and process drops at the
client or server side.
</ecd:Description>
<ecd:Description id="Description2" runat="server">
The control or HTML element should have <b>DropId</b> attribute set to some value in order
to accept nodes' drops.
</ecd:Description>
<ecd:Description id="Description4" runat="server">
Set <b>DragAndDropEnabled="true"</b> for the tree to enable drag and drop its nodes.
Set <b>IsDraggable</b> boolean property for an individual node to enable / disable dragging it.
</ecd:Description>
<ecd:Description id="Description3" runat="server">
Set tree's <b>Drop</b> property to one of the values:</p>
<ul>
<li><b>AutoPostBack</b> - to raise PostBack and server-side <b>NodeMoved</b> event when the node is dropped.</li>
<li><b>AutoClientNodeMove</b> - to move the node at the client side.</li>
<li><b>ScriptResolved</b> - to call a client-side event handler.</li>
</ul>
To define a client-side drop event handler use the following :
<pre class="aspcode">
<ecd:SyntaxHighlight runat="server" ContentType="ASPX" ID="Syntaxhighlight4">
<OnClientAfter NodeDropHandler="AfterDropHandler" />
</ecd:SyntaxHighlight>
</pre>
<b>AfterDropHandler</b> is the name of a function that will be called after a
node is dropped. This function accepts a single parameter of type <b>DragnDrop</b>.
See client API docs for more information regarding client objects and their methods.
</ecd:Description>
</ecd:DescriptionView>
</td>
</tr>
</table>
</td>
</tr>
</table>
<ec:CodeViewTab id="CodeViewTab1" runat="server">
<ec:TabItem runat="server" Text="aspx" ID="Tabitem1">
<pre class="aspcode">
<ecd:SyntaxHighlight runat="server" ContentType="ASPX" OutputFile="Advanced/DropOtherControl.ascx" ID="Syntaxhighlight1"/>
</pre>
</ec:TabItem>
<ec:TabItem runat="server" Text="C#" ID="Tabitem2">
<pre class="aspcode">
<ecd:SyntaxHighlight runat="server" ContentType="C#" OutputFile="Advanced/DropOtherControl.ascx.cs" ID="Syntaxhighlight2"/>
</pre>
</ec:TabItem>
<ec:TabItem runat="server" Text="VB" ID="Tabitem3">
<pre class="aspcode">
<ecd:SyntaxHighlight runat="server" ContentType="VB" OutputFile="Advanced/DropOtherControl_vb.ascx.vb" ID="Syntaxhighlight3"/>
</pre>
</ec:TabItem>
</ec:CodeViewTab>