This article is mainly on the JS control asp.net of the TreeView control Select or cancel the sample code is introduced, the need for friends can come to the reference, I hope to help you.
The code is as follows: <script language= "JavaScript" > /* function Name: Checknode (CurrentNode), ParentNode ( CurrentNode), Childnode (currentnode) function function: To implement the TreeView with CheckBox 1, select parent node its child nodes are all selected 2, the selection of all the child nodes, the choice of the parent node will also be canceled use method: 1, add Checknode in <head></head> Center ( CurrentNode), ParentNode (CurrentNode), Childnode (CurrentNode) 2, *.aspx.cs in Page_Load () Add YourTreeView.Attribute.Add to the event ("Oncheck", "Checknode (Yourtreeview.gettreenode (yourtreeview.clickednodeindex))" ) / //recursive traverse all sub nodes function Checknode (CurrentNode) { var childnode=new Array (); var PARENTN Odechild=new Array (); var ischecked; Childnode=currentnode.getchildren (); if (currentnode.getattribute (' checked ')) { Ischecked=true; } Else { ischecked=false &NB Sp } //parent node processing if (currentnode.getparent ()!=null) { &N Bsp Check processing if (Currentnode.getattribute (' Checked ')) { parentnode (CurrentNode); } Else //uncheck the { CHILDN Ode (CurrentNode); } } Else { //Nothing done &NB sp; } //Sub-node processing if (childnode.length>0) { & nbsp for (var i=0;i<childnode.length;i++) { Childnode.setattribute (" Checked ", ischecked); if (Childnode.getchildren (). Length>0) { checknode (childnode); } } &N bsp; } } //Recursive selected parent node function PARENTN Ode (CurrentNode) { if (currentnode.getparent ()!=null) { Currentnode.getparent (). setattribute (' Checked ', true); //Recursive call ParentNode (CurrentNode) to traverse the parent node of the upper level ParentNode (Currentnode.getparent () ); } } //recursive uncheck parent node function Childnode ( CurrentNode) { if (currentnode.getparent ()!=null) { & nbsp var checkedcount=0; var childnode=currentnode.getparent (). GetChildren (); for (var i=0;i<childnode.length;i++) &NBsp { if (Childnode.getattribute (' Checked ')) { checkedcount++; & nbsp; } } if (checkedcount==0) { &nbs P Currentnode.getparent (). setattribute (' Checked ', false); } //Recursive call Childnode (CurrentNode) to traverse a higher level of the parent node Childnode ( Currentnode.getparent ()); } } </script> JS recursively traverse all child nodes of a node in the TreeView Copy code code as follows: var allrootnode=new Array (); Allrootnode=treeview1.getchildren (); Alertnode (Allrootnode); function Alertnode (nodearray) {& nbsp; if (parseint (nodearray.length) ==0) return; &NBSp Else { for (i=0;i<nodearray.length;i++ ) { var cnode   ; Cnode=nodearray; alert (Cnode.getattribute ("Text")); if (parseint (Cnode.getchildren (). Length)!=0) & nbsp Alertnode (Cnode.getchildren ()); { } &N Bsp }