选中复选框后,TreeNodeCheckChanged
事件未触发。
Boolean flag;
protected void TreeView1_TreeNodeCheckChanged(object sender, TreeNodeEventArgs e)
{
Label1.Text = "check event fired";
TreeView1.SelectedNode.Checked = true;
if (flag)
{
foreach (TreeNode child in TreeView1.SelectedNode.ChildNodes)
{
child.Checked = true;
}
}
else
{
TreeView1.SelectedNode.Checked = false;
foreach (TreeNode child in TreeView1.SelectedNode.ChildNodes)
{
child.Checked = false;
}
}
}
答案 0 :(得分:3)
经过一番研究,我发现that:这似乎是你想要的。 :)
记录的代码:
<script language="javascript" type="text/javascript">
function postbackOnCheck()
{
var o = window.event.srcElement;
if (o.tagName == 'INPUT' && o.type == 'checkbox' && o.name != null && o.name.indexOf('CheckBox') > -1)
{ __doPostBack("",""); } }
</script>
<asp:TreeView onclick="postbackOnCheck()" ID="treeContent"
runat="server"> ... And so on ... </TreeView>