Home - Forums-.NET - FlyTreeView (ASP.NET) - Wrong NodeTypeID being sent back to server

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Wrong NodeTypeID being sent back to server
Link Posted: 10-Dec-2007 10:41
Hi,

I'm having a problem with my flytreeview. I have a parent node. This parent node is selectable.  Its children nodes are populated on demand. Some of these children are selectable, some are not. If I click on a one of the non-selectable children. Nothing happens, which is good.

Side note: (I had to do the following, CanBeSelected="false" PostBackOnSelect="false", for this to work. If PostBackOnSelect was set to true, the clicking on the node caused a postback, which doesn't make sense to me, since CanBeSelected was already set to false.)

Back to my issue:  After clicking on the non-selectable child node, I then click on the selectable parent node. In my debugger I put a break point in the node selected handler. When it hits this break point, the NodeTypeID is of the non-selectable child node. This is incorrect. I click continue in my debugger at then the node selected break point is hit again, and the nodeTypeId at that point is the correct type for the Parent node. This is correct. At this point, my app is already broken as the code to handle the child node was already executed.

This is occurring in version 4.3.1.74

Is this a bug that may have been fixed in later versions of the dll?

Thanks.
Link Posted: 10-Dec-2007 11:03
Thansk.
From your post it comes that we have two possible bugs:
one with PostBackOnSelect
and the second is nodetype related bug.

Could you create a sample page with your setting and attach it here (zip before), so we can debug it locally and fix issues ASAP.

This is a 100% way.
Link Posted: 10-Dec-2007 11:37
Hi EvgenyT,

I figured out a way to fix my problem. Maybe I did something incorrectly, but it might still be a flytreeview bug though.

When I was generating my nodes in my code, I by default was setting the nodes to be selectable. Then when I set the nodetypeId programatically, I assumed the nodetype attributes would determine if the node was actually selectable or not. This is where the problem was. Though the node type for the child node was set to selectable = false, in, reality it was not. That is why I was then forced to set the PostBackonSelect to false as well.  Here is some demo code to illustrate.



The nodeTypeID for type2 declares CanBeSelected to be false and PostBackOnSelect to be false. I guess the question is, which takes precedence.

Place a break point in the node selected handler. If you click on the child node, nothing will happen. Then click on the parent node. Your break point should hit. If you inspect the node Type ID, it will be of the child node. Click continue, you then will get another hit on your breakpoint, and the parent node type id will be shown. You are getting 2 node selected call backs. I think this is incorrect. But I guess this is debatable. I'm not sure. Thanks for your response though.




<%@ Register Assembly="NineRays.WebControls.FlyTreeView" Namespace="NineRays.WebControls"
    TagPrefix="NineRays" %>




    Untitled Page


    
    
    
        
            
            
            
        
    
    

        
          
        
        
        
          
        
        





        
            
        

        

    Panel

    








using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void myMenu_Command(object sender, NineRays.WebControls.FlyContextMenuCommandEventArgs e)
        {
            panel.Visible = !panel.Visible;
        }

        protected void nodeSelected(object sender, NineRays.WebControls.FlyTreeNodeEventArgs e)
        {
            panel.BackColor = System.Drawing.Color.Green;
        }
    }
}


Link Posted: 11-Dec-2007 07:20
Thanks for the code.

I can explain.

You're using NodeSelected event. This is one of node-level events that are fired one by one, when treeview loads all client-side changes during loadpostdata stage.

If you just need to handle the latest selected node, then you need to handle SelectedNodeChanged event.