I have an ASP.Net 2.0 page containing two UpdatePanels. The first panel contains a TreeView. The second panel contains a label and is triggered by a selection in the tree. When I select node, the label is updated as expected, and the TreeNodeone I clicked becomes highlighted, and the previously selected node is no longer highlighted. However, if the node is the original, selected (highlighted) in the code, behind the highlight is not removed when you select another node.
Markup
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:TreeView ID="TreeView1" runat="server" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">
<SelectedNodeStyle BackColor="Pink" />
</asp:TreeView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="True">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text=" - "></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TreeView1" EventName="SelectedNodeChanged" />
</Triggers>
</asp:UpdatePanel>
The code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TreeView1.Nodes.Add(new TreeNode("Test 1", "Test One"));
TreeView1.Nodes.Add(new TreeNode("Test 2", "Test Two"));
TreeView1.Nodes.Add(new TreeNode("Test 3", "Test Three"));
TreeView1.Nodes.Add(new TreeNode("Test 4", "Test Four"));
TreeView1.Nodes[0].Selected = true;
}
}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
Label1.Text = TreeView1.SelectedValue;
}
First, the first node is selected. Why is its selection not deleted when another node is selected?
In addition, I asked another question about the same setup for which I have no answer. Any help would be appreciated.
. , ChildrenAsTriggers="false" , , , .