We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to implement user prompt whenever the TreeView node is moved or deleted?

Description

When TreeView is enabled with drag and drop or defined to remove nodes, using prompts you can confirm deletion or moving nodes. This prevents you from unintentional dragging or deleting nodes on mishandling.

Solution

You can implement user prompt when a node is dragged and deleted using the following steps.

  1. In the following scenario, deletion is performed using ContextMenu. It defines delete action for TreeView nodes when you click the Delete menu item. Using ClientSideOnClick event of ContextMenu, you can delete the TreeView node using removeNode() API in the client script. Before calling the API, display a prompt message to confirm deletion.

Sample: http://asp.syncfusion.com/demos/web/TreeView/ContextMenu.aspx

  1. Enable drag and drop for the TreeView node, by setting AllowDragAndDrop, AllowDropChild, AllowDropSibling and AllowDragAndDropAcrossControl properties to true. To generate prompt for drag and drop confirmation, define client side script, when drag starts using ClientSideOnNodeDragStarted event. Now, it displays a prompt message to confirm moving node and returns true or false as per your confirmation.

Sample: http://asp.syncfusion.com/demos/web/TreeView/DragandDrop.aspx

Refer to the following code example.

ASPX

 

Article ID: Published Date: Last Revised Date: Platform: Control:
2540 08/26/2014 12/15/2014 ASP.NET Web Forms TreeView
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.