Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1414
AJAX (Smart) Callback for NodeClick event in WebTree
posted

To All,

I have seen significant discussion regarding DemandLoad and a little on callbacks initiated by a WebTree NodeClick.

 

I have wired the NodeClick as such:

protected override void OnInit(EventArgs e)

{

base.OnInit(e);tvUnitNavigator.NodeClicked += new NodeClickedEventHandler(tvUnitNavigator_NodeClicked);

}

 

and created a NodeClicked handler (sort of dumb, just to test):

protected void tvUnitNavigator_NodeClicked(object sender, WebTreeNodeEventArgs e)

{

Node blah = e.Node;

}

I was hoping to save the clicked Node's DataKey to a Session variable for use in a different form.  So, the only server side processing will be to save the node to a Session variable - that is, I really don't want to change the tree and/or rebuild the tree.

Is there a simple solution???

Parents
  • 28464
    posted

    Hello Roger,

    It is a good question. Unfortunately there is no easy solution for that, as far as SmartCallBacks are used (both Automatic and Manual). The idea is that the nodes that come on demand from the server do not really exist on the server-side part of the treeview (hence the performance boost and the ability for the treeview to not refresh). This however comes at a cost - postback events like NodeClick are not supported for nodes that come on demand.

    One possible approach to deal with that would be to hook client-side events from CSOM and in the Before...Click event for example, to store some Node specific value in a hidden field (say, DataKey / DataPath / Text, etc) and then on postback to use that to get the actual node on the server and reconstruct the tree. It will require some coding, but unfortunately is the only way to go with SmartCallBacks.

    Basically, it is a trade-off between speed and flexibility. To gain super-speed of the SmartCallBacks functionality we sacrifice some flexibility (but then again, we do provide the Manual / Automatic modes (without Smart)) that should be helpful in this case.

Reply Children