I work on a web projects in ASP C#, in my MasterPage i have a TreeView and two LinkButton which Collapse and Expand the nodes of the TreeView, both LinkBuutons work properly but after it's Expand or Collapse the TreeView, it's create others TreeViews.
Here is a piece of my masterPage
<body>
<form runat="server">
... //I cut a part of code
<table id="Principal">
<tr>
<td id="Menu" class="auto-style1">
<div style="width : 320px; height : 700px; overflow : auto; ">
<asp:HyperLink Text="Accueil" NavigateUrl="~/Views/Accueil.aspx" runat="server"/>
<br/>
<br/>
<asp:LinkButton ID="btnDevAll" Text="Tout développer" OnClick="devAll_Click" runat="server" /> - <asp:LinkButton ID="btnRedAll" Text="Tout réduire" OnClick="redAll_Click" runat="server" />
<br/>
<asp:TreeView ID="TreeViewMenu" runat="server" ParentNodeStyle-ForeColor="Black" ParentNodeStyle-ImageUrl="~/images/folderclose.gif" >
</asp:TreeView>
</div>
</td>
<td id="Content" style="vertical-align: top; overflow:visible;">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
... //I cut a part of code
</form>
</body>
And now functions to collapse and expand the TreeView
protected void redAll_Click(object sender, EventArgs e)
{
TreeViewMenu.CollapseAll();
}
protected void devAll_Click(object sender, EventArgs e)
{
TreeViewMenu.ExpandAll();
}
Thanks to anyone who will try to solve my problem.