Home - Forums-.NET - FlyTreeView (ASP.NET) - NodeMoved not firing

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

NodeMoved not firing
Link Posted: 15-Aug-2008 06:30
I'm using FlyTreeView version 4.2.1.53 and I need to modify an external database base on dragging and dropping nodes. I understand that the ideal way to do this is to set PostBackOnDropAccept to true and add a handler for NodeMoved (inside the same TreeView) or NodeInserted (another tree). Unfortunately, the drop triggers a post-back, but no events get triggered. I read in another thread that someone had a problem similar to this when handling the OnDrop Javascript event (http://www.9rays.net/forums/viewtopic.php?f=12&t=1144&p=3874&hilit=NodeMoved+NodeInserted&sid=a2f3d8f0686a78aea47a2e95d1e8eb4b#p3874), but I've removed all my Javascript handlers and created a minimal testpage from scratch that never used Javascript and the events still aren't getting triggered on postback. Is there anything I'm missing? Page: [code] Untitled Page
[/code] Code: [code]using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using NineRays.WebControls; namespace TestIt { public partial class TreeTest : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { for (int i = 0; i < 10; i++) { FlyTreeNode n = new FlyTreeNode(i.ToString()); for (char c = 'A'; c < 'D'; c++) n.ChildNodes.Add(new FlyTreeNode(c.ToString())); Tree.Nodes.Add(n); } } Tree.PostBackOnDropAccept = true; Tree.NodeMoved += new FlyTreeNodeMovedEventHandler(Tree_NodeMoved); } void Tree_NodeMoved(object sender, FlyTreeNodeMovedEventArgs e) { Output.Text = e.Node.Text + " moved from " + e.PreviousParent.Text + " to " + e.Node.Parent.Text; } } } [/code]
Link Posted: 15-Aug-2008 07:11
NodeXxx events are fired at LoadPostData stage, when treeview applies client-side changes one by one.
So you need to move
Tree.NodeMoved += new FlyTreeNodeMovedEventHandler(Tree_NodeMoved);
to
Page_Init method, not Page_Load
Link Posted: 15-Aug-2008 07:31
I figured it was something simple I was missing. It works now. Thanks.