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

NavigateURL property empty, don't redirect

4 Answers 103 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
CBARS
Top achievements
Rank 2
CBARS asked on 16 Jan 2009, 09:34 AM
I have a RadTreeView that is bound to an XML file. The XML file contains the Text and NavigateURL property for each RadTreeNode item. However, when the NavigateURL property is empty for an item (which is the case for items that do not have a page of their own, but has child items) and I click on it, my browser tries to redirect to "" (as the NavigateURL is empty), and throws a page not found error.

Is there some way I can check (in JavaScript) whether the NavigateURL property actually contains something, and only redirect when this is the case?

4 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 16 Jan 2009, 11:40 AM
Hello there,

I suggest you subscribe to OnClientItemClicking event of RadTreeView and check whether the node has NavigateUrl in the event handler like this:

<script type="text/javascript">  
    function nodeClicking(sender, args)  
    {  
        var node = args.get_node();  
        if(node.get_navigateUrl() == "")  
            args.set_cancel(true);  
    }  
</script> 


Regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
CBARS
Top achievements
Rank 2
answered on 19 Jan 2009, 11:01 AM
Hi

In this case (well, probably any RadControl), does the client side event handler get executed first, and then if args.set_cancel is not set, the server side event handler is executed?

Also, is it possible to use this event handler on a .ascx User Control? Do I have to add the script to the user control, or the page it is implemented on?

Marcel

0
Yana
Telerik team
answered on 19 Jan 2009, 12:16 PM
Hi Marcel,

Actually when NavigateUrl is not provided in the xml or set to "" RadTreeNode is not supposed to navigate by default, so it is weird that you have this issue. Could you please isolate the problem in a small running project and send it to us so we to be able to test it locally? Thanks

Kind regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
CBARS
Top achievements
Rank 2
answered on 21 Jan 2009, 08:53 AM
Hi

I'll put something together.

In the meanwhile... is there a way to cancel the redirect, but still have the clicked node selected?

If I do args.set_cancel(true);, my server side code is not executed. I still need the node selected client-side (for visual reference), the server side code for NodeClicked to execute, and not to redirect.
Tags
TreeView
Asked by
CBARS
Top achievements
Rank 2
Answers by
Yana
Telerik team
CBARS
Top achievements
Rank 2
Share this question
or