开发者

Calling code-behind method on TreeNode click

I want to call a code-behind method when a TreeNode is clicked in my TreeView. I would imagine this isn't difficult to do, but I can't find a good example of how to do it.

I've looked at TreeNodeSelectAction, 开发者_JS百科but that appears to just be an enumeration, so I'm wondering how I can call my own code when a node is clicked.


Try add the SelectedNodeChanged event handler to the TreeView control. Then, you can select the method by the TreeNode name.

protected void MyTreeView_SelectedNodeChanged(object sender, EventArgs e)
{
    TreeView treeView = sender as TreeView;
    if (treeView != null)
    {
            TreeNode treeNode = treeView.SelectedNode;
    }
}

Hope it helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜