To sum up this work, I understand several key points:
1. javascript can directly reference the. NET Server-side control, but the problem is that the Control ID will automatically add a namespace after compilation, so pay special attention here.
2. Using JavaScript makes it convenient and effective to perform operations on the Treeview without the need for PostBack.
3. The display of the Space status is different from that of the actual storage, so pay attention to it.
Add the following to the C # file: Treeview. Attributes. Add ( " Oncheck " , " Tree_oncheck () " );
Major Javascript Code As follows: < Script Language = " Javascript " >
<! --
Function Tree_oncheck ()
{
VaR Node = Treeview. gettreenode (event. treenodeindex );
VaR Pchecked = Node. getattribute ( " Checked " );
Setcheck (node, pchecked );
Treeview. queueevent ('oncheck', node. getnodeindex ());
}
Function Setcheck (node, PC)
{
VaR Childnode = New Array ();
Childnode = Node. getchildren ();
If (Parseint (childnode. length) ! = 0 )
{
For ( VaR I = 0 ; I < Childnode. length; I ++ )
{
VaR CNode = Childnode [I];
If (CNode. getattribute ( " Checked " ) ! = PC)
{
If (Parseint (cNode. getchildren (). length) ! = 0 )
Setcheck (cNode, PC );
CNode. setattribute ( " Checked " , PC );
Treeview. queueevent ('oncheck', cNode. getnodeindex ());
}
}
}
}
// -->
</ Script >
To implement the entire function, you need to modify a bug of the Microsoft Treeview control.
You need to modify Inetpub \ wwwroot \ webctrl_client \ defaults 0 \ Treeview. HTC.
Put the first line in function docheckboxclick (EL,
El. Checked =! El. checked;
Changed:
El. Checked =! El. getattribute ("checked ");
Blogger Note: This articleArticleThe method mentioned above will go wrong after trial. For more comprehensive solutions, see Treeview parent-child linkage effect to keep the node status consistent.