drag and drop into textbox not working

2 posts, 0 answers
  1. Kristopher
    Kristopher avatar
    1 posts
    Member since:
    Jan 2014

    Posted 04 Oct Link to this post

    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' });

                    }
                }

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 07 Oct Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top