Pb NodeClick Event - RadTreeView

2 posts, 0 answers
  1. aurelie
    aurelie avatar
    1 posts
    Member since:
    Feb 2008

    Posted 04 Feb 2008 Link to this post

    I have a problem with my radTreeView with sharepoint. I would like to put an event on the click of the treeview.

    I tried to put in my aspx code :

    <script runat="server">

    protected void RadTreeView1_NodeClick(object o, RadTreeNodeEventArgs e)

    {

    Label1.Text = TreeView1.SelectedNode.Value.ToString();

    }

    </script>

    (I put AutoEventWireup="true" )

    but when i click on an item of my treeview, my application doesn't execute this function.

    I tried also to put the function

    protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)

    {

    Label1.Text = TreeView1.SelectedNode.Value.ToString();

    }

    in my aspx.cs code and I also put :

    protected override void OnInit(EventArgs e)

    {

    InitializeComponent();

    base.OnInit(e);

    }

    private void InitializeComponent()

    {

    this.RadTreeView1.NodeClick += new Telerik.WebControls.RadTreeView.RadTreeViewEventHandler(this.RadTreeView1_NodeClick);

    }

    But when I execute my application this function doesn't work, it's not executed.

    In the both cases, when I click, my application is redirected to the URL of the node. I would like the function TreeView1_SelectedNodeChanged is executed before the redirection.

    Thank you for your help

  2. Nikolay
    Admin
    Nikolay avatar
    3997 posts

    Posted 04 Feb 2008 Link to this post

    Hello aurelie,

    First of all, please make sure that the AutoPostBack property of the treeview is enabled.

    Also, you cannot execute a NodeClick and page redirection(using the NavigateUrl property of the node) at the same time. You can use the following approach to accomplish the task:
    1. Store the url in the Value property of the node
    2. Hook on the BeforeClientClick event and use window.open to open a new page. Get the url from the node's Value. For more details please refer to the RadTreeNode Client-Side object model
    3. Make sure to return true in the BeforeClientClick event handler
    4. The NodeClick event will be fired right after
    Hope this helps.

    Regards,
    Nick
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

Back to Top