Home - Forums-.NET - FlyTreeView (ASP.NET) - possible problem in PostBackOnCheck and Uncheck

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

possible problem in PostBackOnCheck and Uncheck
Link Posted: 08-Nov-2007 05:33
hi,
i think there's a problem when Setting dynamically everything in code :
PostBackOnCheck and PostBackOnUnchek to true and adding the eventhandler for the NodeCheckedChanged event
it doesn't work !

any help thx !
Link Posted: 08-Nov-2007 10:31
To test your case, I modified standard Demo_Checkboxes.aspx
to include:
PostBackOnCheck=\"true\" PostBackOnUncheck=\"true\" OnNodeCheckedChanged=\"flyTreeView_NodeCheckedChanged\"


and



    protected void flyTreeView_NodeCheckedChanged(object sender, FlyTreeNodePropertyChangedEventArgs e)
    {

    }


So setting the breakpoint to flyTreeView_NodeCheckedChanged causes debugger to break when I check/uncheck nodes.

Seems to work ok.
Link Posted: 08-Nov-2007 11:30
i don't know how you did, but me too i changed the same page so that it contains this code in code behind

public partial class Demo_CheckBoxes : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        flyTreeView.PostBackOnCheck = true;
        flyTreeView.PostBackOnUncheck = true;

        flyTreeView.NodeCheckedChanged += new NineRays.WebControls.FlyTreeNodePropertyChangedEventHandler(flyTreeView_NodeCheckedChanged);
    }

    void flyTreeView_NodeCheckedChanged(object sender, NineRays.WebControls.FlyTreeNodePropertyChangedEventArgs e)
    {
        throw new Exception(\"The method or operation is not implemented.\");
    }
}


and you can put a breakpoint in the eventhandler and you'll see that it doesn't enter the eventhandler and the page refreshes when you change a checkbox state and if it enters as you see an exception will be thrown

so i think there's a problem unless i'm doing a wrong thing.
i need this to work to update some other controls state and i can't figure out how to solve the problem
thx
Link Posted: 08-Nov-2007 22:25
Oh, I see.

You're setting
flyTreeView.NodeCheckedChanged += ....

at Page_Load (fired from OnLoad).

But all node-level events are fired at LoadPostData stage, one by one, all client-side actions are applied to FlyTreeView.

So you need to move your event handler assignment to ASPX markup or to OnInit:
protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    flyTreeView.NodeCheckedChanged += new FlyTreeNodePropertyChangedEventHandler(flyTreeView_NodeCheckedChanged);
}

void flyTreeView_NodeCheckedChanged(object sender, FlyTreeNodePropertyChangedEventArgs e)
{
    throw new Exception(\"The method or operation is not implemented.\");
}


Regular events (SelectedNodeChanged, etc.) are fired after OnLoad, but all NodeSOMEPROPERTYChanged - are events of a special type, fired one by one at LoadPostData.
Link Posted: 08-Nov-2007 23:22
i see, i didn't test it yet...
thx