This is a migrated thread and some comments may be shown as answers.

drag and drop into textbox not working

1 Answer 33 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kristopher
Top achievements
Rank 1
Kristopher asked on 04 Oct 2016, 11:21 PM

Hello, i am trying to perform drag and drop from tree view into a textbox control.  However, i m having some issues.  My treeview is databound to a sqldatasource if that makes a difference.  can someone please take a look at my code...thanks

protected void RadTreeView1_NodeDrop(object sender, Telerik.Web.UI.RadTreeNodeDragDropEventArgs e)
        {
            if (TextBox1.ClientID == e.HtmlElementID)
            {
                TextBox1.Text = String.Empty;

                foreach (RadTreeNode node in e.DraggedNodes)
                {
                    {
                        //problem area!
                        TextBox1.Text = sender.ToString();
                            

                    }

                    if (TextBox1.Text.Length > 0)
                        TextBox1.Text = TextBox1.Text.TrimEnd(new char[] { ',', ' ', '\n' });

                }
            }

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 07 Oct 2016, 01:58 PM
Hi Kristopher,

The following demo shows a similar scenario of dropping a node over a RadTextBox, but the approach is the same when using an asp:TextBox. Apart from drag and drop over a TextBox the demo showcases drag and drop over other controls, but for your scenario the onNodeDragging and onNodeDropping handlers will be relevant as well as the droppedOnInput and dropOnHtmlElement functions. Please note that in the droppedOnInput function the following line: args.set_cancel(true); cancels the OnClientNodeDropping event, thus the server-side NodeDrop event will not fire. So if you want to access the id of the TextBox in this event you will have to remove this line.

Regards,
Ivan Danchev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
TreeView
Asked by
Kristopher
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or