Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Treeview > How to get node.attributes.add("key","value") key
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered How to get node.attributes.add("key","value") key

Feed from this thread
  • faisal avatar

    Posted on May 18, 2011 (permalink)

    Hi,

    i am working on telerik tree view. i am adding a node like that

    RadTreeNode assetnode = new RadTreeNode();
                                            assetnode.Text = "a";
                                            assetnode.Value = "1";
                                            assetnode.ImageUrl = "~/Images/Lorry.png";
    assetnode.Attributes.Add("CompanyNode", "abcd";
                                            Treeview.Nodes.Add(assetnode);

    i want now to get the attribute key and value. how to get that.
    Plz help me

    With regards,

    Faisal

  • Posted on May 19, 2011 (permalink)

    Hello Faisal,

    You can access the attribute value either from client side or server side.
    Here is a sample code.

    server side.
    protected void Button1_Click(object sender, EventArgs e)
       {
           RadTreeNode node = RadTreeView1.FindNodeByText("a");
           Response.Write(node.Attributes["CompanyNode"]);
       }

    ClientSide:
    function getAttribute()
      {
        treeView = $find("<%= RadTreeView1.ClientID %>");
        var node=   treeView.findNodeByText("a")
        var value= node.get_attributes().getAttribute("CompanyNode");
        alert(value);
       }

    Thanks,
    Shinu.

  • faisal avatar

    Posted on May 19, 2011 (permalink)

    Hi,

    thanks for your reply.

    yes i know this way to access like node.Attributes["CompanyNode"]);

    but i need the scenario like. i clicked on a node and i have that value. clickednode.value. in this case how 
    i can access its attribute where i dont know its attribute name node.Attributes[ attribute name????]);

    With Regards,

    Faisal

  • Posted on May 20, 2011 (permalink)

    Hello Faisal,

    You can get the attribute name by the property _key.

    javascript:
    for (var i = 0; i < node.get_attributes()._keys.length; i++)
                alert(node.get_attributes()._keys[i]);//returns the attribute name.

    Thanks,
    Shinu.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Treeview > How to get node.attributes.add("key","value") key