This is a migrated thread and some comments may be shown as answers.

Determining Expanded Node at Page_Load

3 Answers 70 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 18 Nov 2011, 09:55 AM
I'm wondering if it's possible, when a node is expanded in the RadTreeView,  to know on the Page_Load (this is called after a node is expanded, but before the server side Expand event) the conditions of the post back - so the SelectedNode, whether it was Expanded etc.  I've tried using the client side events OnNodeExpanding and OnNodeExpanded to inject information (in various ways) to pick up in the Page_Load but although  these client methods are called first the information is never present in the Page_Load.  Thinking about using an Ajax call to a method in the code from these methods - might be able to do something there.  The reason for this is simply that I need to determine whether a node was clicked at Page_Load - and make some decisions based on that.  Any ideas?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Nov 2011, 11:38 AM
Hello,

You can try the following approach to get the index of expanded node on PageLoad.

JS:
<script type="text/javascript">
 function OnClientNodeExpanding(sender, args)
   {
        var hidden = document.getElementById("HiddenField1");
        var index = args.get_node().get_index();
        hidden.value = index;
        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
   }
</script>

C#:
protected void Page_Load(object sender, EventArgs e)
   {
      String s=  HiddenField1.Value;
   }
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
   {
 
   }

Note: Add one RadAjaxManager on ASPX.

Thanks,
Princy.
0
Matt
Top achievements
Rank 1
answered on 18 Nov 2011, 12:44 PM
Hey - just tried this.  The call to _AjaxRequest and the ability to get the value from the control.. happen too late.  Basically I see a OnLoad in the code after the node expand - check the hidden field values (and everything else I've tried here .. cookies, etc) but the data isn't present at that point.  Then I there's a small pause and another page load occurs - this time I see the data, also see the _AjaxRequest method get hit.  It's the fact the events (OnLoad, PageLoad) are getting called immediately after the Expand but don't contain anything I've injected.
0
Bozhidar
Telerik team
answered on 22 Nov 2011, 12:32 PM
Hi Matt,

If you want only to know whether a node has been expanded, you could use the method described by Princy.
To avoid the double load, don't use the last line of the function (the ajaxRequest).
If that doesn't work please send a sample project and/or say exactly what you need to do in the Page_load, and why you can't do it in the Expand event.

Regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
TreeView
Asked by
Matt
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Matt
Top achievements
Rank 1
Bozhidar
Telerik team
Share this question
or