First set the property autopostback = "true", so there will be valid for onchange = "trecess_chkchange".
Sub TreeView2_chkchange (Byval e as treeviewclickeventargs) Handles TreeView2.check
CheckAllChildNodes (TreeView2.Getnodefromindex (E.NODE), TRUE
Session ("groups") = nodeshow (TreeView2.nodes)
Response.write ("session =" & session ("groups")))
End Sub
Sub CheckallchildNodes (Byval NodeChecked As Boolean)
Dim Node as Treenode
For Each Node in Treenode.nodes
Node.checked = nodechecked
If node.checked = true kil
If node.nodes.count> 0 THEN
Me.checkAllChildNodes (Node, NodeChecked)
END IF
END IF
NEXT
End Sub
Function Nodeshow (Byval Treenode As TreenodeCollection) AS String
Dim Node as Treenode
For Each Node in Treenode
IF node.checkbox kil
If Node.checked Then
Strowids = strgroupids & node.text & "", "
END IF
If node.nodes.count> 0 THEN
Nodeshow (node.nodes)
END IF
END IF
NEXT
Return StrGroupIDS
END FUNCTION