Hi,
Base on your description, do you want to use the linkbutton to expand or collapse menu items, and change the linkbutton's text according to menu's status at the same time, right?
Below is my test code, hope it helps:
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" OnTreeNodeExpanded="TreeView1_TreeNodeExpanded" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" OnTreeNodeCollapsed="TreeView1_TreeNodeCollapsed" ShowLines="True">
</asp:TreeView>
<asp:LinkButton ID="lbClose" runat="server" OnClick="lbClose_Click">Close Menu</asp:LinkButton>
The codebehind of the linkbutton:
protected void lbClose_Click(object sender, EventArgs e)
{
TreeNode tn = this.TreeView1.Nodes[0];
if (tn.Expanded == true)
{
this.TreeView1.CollapseAll();
this.lbClose.Text = "open Menu";
}
else
{
this.TreeView1.ExpandAll();
this.lbClose.Text = "Close Menu";
}
}
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Yours sincerely,
Amanda Wang
Microsoft Online Community Support