I am using the css treeview adapter. It appears that when I do a postback using a checkbox control and set the items programatically, the items do not stay checked. If I use a button to set the items, it works fine. If anybody has any idea, please let me know.
Here is a simple test:
HTML:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language='JavaScript' type='text/javascript' src='/scripts/CascadeCheckmarks.js'></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="chkCheckItem" runat="server" Text="Check last two items" AutoPostBack="true" />
<br />
<asp:Button ID="btnCheckItem" runat="server" Text="Check first two items" />
<asp:TreeView ID="tvListProspect" OnClientClickedCheckbox="CascadeCheckmarks(event)"
runat="server" CssSelectorClass="SicTreeView" ShowCheckBoxes="All">
</asp:TreeView>
</div>
</form>
</body>
</html>
vb:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
LoadList()
End If
End Sub
Private Sub LoadList()
Dim node As TreeNode
node = New TreeNode
node.Value = "0"
node.Text = "0"
node.ShowCheckBox = True
Me.tvListProspect.Nodes.Add(node)
node = New TreeNode
node.Value = "1"
node.Text = "1"
node.ShowCheckBox = True
Me.tvListProspect.Nodes.Add(node)
node = New TreeNode
node.Value = "2"
node.Text = "2"
node.ShowCheckBox = True
Me.tvListProspect.Nodes.Add(node)
node = New TreeNode
node.Value = "3"
node.Text = "3"
node.ShowCheckBox = True
Me.tvListProspect.Nodes.Add(node)
node = New TreeNode
node.Value = "4"
node.Text = "4"
node.ShowCheckBox = True
Me.tvListProspect.Nodes.Add(node)
node = New TreeNode
node.Value = "5"
node.Text = "5"
node.ShowCheckBox = True
Me.tvListProspect.Nodes.Add(node)
End Sub
Protected Sub btnCheckItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheckItem.Click
Me.tvListProspect.Nodes(0).Checked = True
Me.tvListProspect.Nodes(1).Checked = True
End Sub
Protected Sub chkCheckItem_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkCheckItem.CheckedChanged
Me.tvListProspect.Nodes(4).Checked = chkCheckItem.Checked
Me.tvListProspect.Nodes(5).Checked = chkCheckItem.Checked
End Sub