Home - Forums-.NET - FlyTreeView (ASP.NET) - Calling ajax functions will not be executed

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Calling ajax functions will not be executed
Link Posted: 24-Mar-2009 08:45
Hi, trying to call ajax functions within flyTreeView_SelectedNodeChanged function or flyTreeView_PopulateNodes function will not be executed.
For Example, if the following actions done from flyTreeView_SelectedNodeChanged will not be work:
1-  ScriptManager.RegisterStartupScript(Page, Page.GetType(), "frreqfg", "alert('test alert.');", True)

2- trying to update updatepanel (by calling myupdatepanel.update) will not work

By the way our flytreeview is not within updatepanel.
Link Posted: 24-Mar-2009 09:44
So when do you call RegisterStartupScript?
At async postback, callback or ..?

Ideally, can you put test code here, so I can run and see what is the problem with it.
Link Posted: 24-Mar-2009 10:02
[quote="EvgenyT"]So when do you call RegisterStartupScript?
At async postback, callback or ..?

Ideally, can you put test code here, so I can run and see what is the problem with it.



I call RegisterStartupScript in    
Protected Sub flyTreeView_SelectedNodeChanged(ByVal sender As Object, ByVal e As NineRays.WebControls.SelectedNodeChangedEventArgs) Handles flyTreeView.SelectedNodeChanged

In regard to test code, i will send it shortly.
Link Posted: 24-Mar-2009 10:41
The attached is test code example.
In the example an alert box should occur and an updatepanel should be updated whenever user selectnode or populate node but they do not!
Something else selectnode function does not fired when user select node!
Link Posted: 24-Mar-2009 22:31
Ok, I see.

First I modified FlyTreeView to cause postback on select : PostBackOnSelect="true"
(SelectedNodeChanged event does not fire untill postback).

Second, I added to UpdatePanel Triggers to enable async postback instead of regular postback:

    
        
    
    ..........


This way it works for me.

Also, you shouldn't do anything except adding nodes in flyTreeView_PopulateNodes handler.
It is called at callback (not postback) so only new nodes are sent to client, and nothing else.
Link Posted: 25-Mar-2009 01:30
It solved the problem but unfortunately it created another important problem, the tree nodes now does not populated when you click on them, just "Loading..." text appears without populating! if you remove PostBackOnSelect="true" it populated but we cannot remove PostBackOnSelect="true" because we need it.
Link Posted: 25-Mar-2009 02:17
Oh, I see.

Then, just some additional Javascript required.
Just put some handler into FlyTreeView.OnSelectedNodeChangingJavascript.
Then just call __doPostBack() from it to refresh updatepanel (like described here):
http://encosia.com/2007/07/13/easily-refresh-an-updatepanel-using-javascript/
Link Posted: 25-Mar-2009 02:50
Thank you for the prompt response. Actually I'm sorry I'm not a professional developer, could you please just show me how to do that in the prevoius test code?
Link Posted: 25-Mar-2009 02:57
Please note we need to get the value of the selected node whenever the node selected.
Link Posted: 26-Mar-2009 02:09
Another idea,
wouldn't it be easier for you just to put FlyTreeView into UpdatePanel also and set PostBackOnExpand to true?

This way you get working everything outofbox without additional javascript.