Describe the requirements:
There are three first-layer nodes, and each of the three first-layer nodes has three to five subnodes. Select one subnode under each layer, and click another button when submitting the node. This function can be implemented in the last demo, but you can select multiple options if you are directly in the checkbox instead of clicking nodes. After that, I processed it as not displaying the checkbox, and then clicked it to display the checkbox. This prevents the user from directly clicking the checkbox and selecting two under a parent node. However, the boss requires that all checkpoints be available, and the checkbox and node must have the same effect. All I have always thought that when a user clicks the checkbox before a node, it is also equivalent to a node, that is, the click can be triggered on the client.
<Script language = "JavaScript">
Function checkone ()
{
VaR cIndex = treeview1.clickednodeindex;
VaR TMP = cIndex. Split (".");
If (TMP. Length = 2) // indicates that all nodes are layer-2nd nodes.
{
VaR pnode = treeview1.gettreenode (cIndex );
VaR parentnode = pnode. getparent ();
VaR nodearray = new array ();
Nodearray = parentnode. getchildren ();
For (VAR I = 0; I <nodearray. length; I ++)
{
VaR cNode = nodearray [I];
CNode. setattribute ('checked', 'false ');
If (cNode. getattribute ("text") = pnode. getattribute ("text "))
{
CNode. setattribute ('checked', 'true ');
Document. All ("hidden1"). value = cNode. getattribute ("text ");
}
}
}
}
</SCRIPT>
<Div style = "font-size: 12px; Z-INDEX: 101; left: 8px; position: absolute; top: 8px "ms_positioning =" text2d "> <font face =" Times New Roman "> describe the requirements in detail: <br>
There are three first-layer nodes, and each of the three first-layer nodes has three to five subnodes. Select one subnode under each layer, and click another button when submitting the node. This function can be implemented in the last demo, but you can select multiple options if you are directly in the checkbox instead of clicking nodes. After that, I processed it as not displaying the checkbox, and then clicked it to display the checkbox. This prevents the user from directly clicking the checkbox and selecting two under a parent node. However, the boss requires that all checkpoints be available, and the checkbox and node must have the same effect. All I have always thought that when a user clicks the checkbox before a node, it is also equivalent to a node, that is, the click can be triggered on the client. </Font> <br>
<Br>
</Div>
<Iewc: Treeview id = "treeview1" style = "Z-INDEX: 102; left: 8px; position: absolute; top: 136px" runat = "server">
<Iewc: treenode text = "node0" expanded = "true">
<Iewc: treenode checkbox = "true" text = "node3"> </iewc: treenode>
<Iewc: treenode checkbox = "true" text = "node4"> </iewc: treenode>
<Iewc: treenode checkbox = "true" text = "node5"> </iewc: treenode>
</Iewc: treenode>
<Iewc: treenode text = "node1">
<Iewc: treenode text = "node6"> </iewc: treenode>
<Iewc: treenode text = "node7"> </iewc: treenode>
<Iewc: treenode text = "node8"> </iewc: treenode>
</Iewc: treenode>
<Iewc: treenode text = "node2">
<Iewc: treenode text = "node9"> </iewc: treenode>
<Iewc: treenode text = "node10"> </iewc: treenode>
<Iewc: treenode text = "node11"> </iewc: treenode>
</Iewc: treenode>
</Iewc: Treeview> <input id = "hidden1" style = "Z-INDEX: 103; left: 24px; position: absolute; top: 296px" type = "hidden"
Name = "hidden1" runat = "server">
<Asp: button id = "button1" style = "Z-INDEX: 104; left: 24px; position: absolute; top: Running PX" runat = "server"
TEXT = "Submit"> </ASP: button>
<Asp: Label id = "label1" style = "Z-INDEX: 105; left: 96px; position: absolute; top: 448px" runat = "server"
Width = "280px" forecolor = "red" font-size = "12px"> </ASP: Label>
Imports Microsoft. Web. UI. webcontrols
Private sub page_load () sub page_load (byval sender as system. Object, byval e as system. eventargs) handles mybase. Load
Treeview1.attributes. Add ("oncheck", "javascript: checkone ();")
Treeview1.attributes. Add ("onclick", "javascript: checkone ();")
Dim tnode as treenode
For each tnode in treeview1.nodes (0). Nodes
If tnode. Text = hidden1.value. Trim () then
Tnode. Checked = true
Else
Tnode. Checked = false
End if
Next
End sub
Private sub button#click () sub button#click (byval sender as system. Object, byval e as system. eventargs) handles button1.click
Label1.text = "the node you selected is:" + hidden1.value
End sub