直接在TreeView的属性上加入:OnClick="OnTreeNodeChecked()"
或者:MyTree.Attributes.Add("OnClick", "OnTreeNodeChecked()");
页面写入以下JavaScript: <script language ='javascript' type='text/javascript'> function OnTreeNodeChecked() { var ele = event.srcElement; if(ele.type=='checkbox') { var childrenDivID = ele.id.replace('CheckBox','Nodes'); var div = document.getElementById(childrenDivID); if(div==null)return; var checkBoxs = div.getElementsByTagName('INPUT'); for(var i=0;i<checkBoxs.length;i++) { if(checkBoxs[i].type=='checkbox') checkBoxs[i].checked=ele.checked; } } } </script>
|
请发表评论