如何获得点击节点文本的RadTreeView



如何在c#中获得RadTreeView中单击节点的文本?我添加了OnNodeClick事件,但它没有触发。请告诉我如何在c#中获取单击节点的文本。

ASP。净:

<telerik:RadTreeView ID="CandidatesTreeMenu" OnClientNodeClicked="ClientCandidateMenuNodeClicked" Skin="Vista" runat="server" OnNodeClick="CandidatesTreeMenu_NodeClick">
    <Nodes>
        <telerik:RadTreeNode Text="Added" NavigateUrl="NewCandidateList.aspx?type=recently">
        </telerik:RadTreeNode>
        <telerik:RadTreeNode Text="Candidates" NavigateUrl="NewCandidateList.aspx?type=My">
        </telerik:RadTreeNode>
    </Nodes>
</telerik:RadTreeView>

背后的代码:

protected void CandidatesTreeMenu_NodeClick(object sender, RadTreeNodeEventArgs e)
{
    try
    {
        string CheckNodeName = e.Node.Text;
    }
    catch { }
}

您需要在用户控件page_load事件中的每个帖子上重新绑定。下面是我在ascx:

中使用的代码
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        CandidatesTreeMenu.NodeClick += CandidatesTreeMenu_NodeClick;
    }
    protected void CandidatesTreeMenu_NodeClick(object sender, RadTreeNodeEventArgs e)
    {
        string CheckNodeName = e.Node.Text;
    }
</script>
<telerik:RadScriptBlock runat="server">
    <script type="text/javascript">
        function ClientCandidateMenuNodeClicked(sender, args) {
            // noop
        }
    </script>
</telerik:RadScriptBlock>
<telerik:RadTreeView ID="CandidatesTreeMenu" OnClientNodeClicked="ClientCandidateMenuNodeClicked" Skin="Vista" runat="server">
    <Nodes>
        <telerik:RadTreeNode Text="Added" NavigateUrl="NewCandidateList.aspx?type=recently">
        </telerik:RadTreeNode>
        <telerik:RadTreeNode Text="Candidates" NavigateUrl="NewCandidateList.aspx?type=My">
        </telerik:RadTreeNode>
    </Nodes>
</telerik:RadTreeView>

相关内容

  • 没有找到相关文章

最新更新