Revert selection on form cancel

2 posts, 0 answers
  1. Samuel
    Samuel avatar
    10 posts
    Member since:
    Jan 2009

    Posted 26 Mar 2009 Link to this post

    Scenario: I have a tree view on my page, and the code-behind is handling the Node Click event. Thus the tree posts to the form when the user clicks a node. However, I have custom javascript to do form checking and cancel the form under certain conditions. I want the tree view to revert its selection if the form is canceled.

    The problem is that the tree view is in a separate web part from the web part that emits the form validation script, so the form validation script doesn't know the ID of the tree view, and can't even necessarily assume that the part with the tree is on the page. What would you suggest I do to solve my problem?
  2. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 30 Mar 2009 Link to this post

    Hello Samuel,

    You can try the following:
    1. define a global variable, e.g.

        var treeViewID;

    2. Subscribe to OnClientLoad event of the treeview and set the global variable to the ID of the treeview:
    function onClientLoadHandler(sender, e) 
       treeViewID = sender.get_id(); 

    Now, you can use the treeViewID global variable to find the treeview in your validation code:

    var tree = $find(treeViewID);

    I hope this will get you started.

    All the best,
    Veselin Vasilev
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top