Preserving Expand/Collapse state of TreeView across pages

Last post 07-24-2008 2:19 AM by sabucalex. 2 replies.

Sort Posts:

  • Preserving Expand/Collapse state of TreeView across pages

    07-22-2008, 4:19 PM
    • Contributor
      2,247 point Contributor
    • ShailAtlas
    • Member since 07-18-2006, 5:07 PM
    • Norway
    • Posts 546

    Hello All,

    I have a TreeView on my master page. It has two levels. The level one has expand/collapse option. When I expand and collapse any node at level 1, I want to preserve that state across my pages. I am referring to the article at http://msdn.microsoft.com/en-us/magazine/cc163598.aspx

    Now the problem is in last peice where they say to keep the TreeView in a UpdatePanel. Can anybody have some better solution. Once again let me tell you what I want to do -

    "I have a treeview on master page. It has 2 levels, with expand collapse on level 1 nodes. If a user expand and collapse the nodes, I need to preserve that state to other pages also"

    Thank You,

    Shail

  • Re: Preserving Expand/Collapse state of TreeView across pages

    07-24-2008, 12:35 AM
    Answer

    Hi,

    ShailAtlas:
    Now the problem is in last peice where they say to keep the TreeView in a UpdatePanel. Can anybody have some better solution. Once again let me tell you what I want to do -

    I am not sure you can implement it in the UpdatePanel, that's because there are some compatible problems with the UpdatePanel Controls, you can refer the part of Controls that Are Not Compatible with UpdatePanel Controls  of this link: http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx.

    About how to maintain the treeview state across your site in a master page, you can refer this thread:  http://forums.asp.net/p/1022893/1387445.aspx 

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Preserving Expand/Collapse state of TreeView across pages

    07-24-2008, 2:19 AM
    • Member
      77 point Member
    • sabucalex
    • Member since 07-26-2007, 11:06 PM
    • Cochin
    • Posts 17

    hi friend

    add this in pageload event

     protected void Page_Load(object sender, EventArgs e)
        {
            TreeView1.CollapseAll();

            if (TreeView1.SelectedNode != null && TreeView1.SelectedNode.Parent != null)
            {
                TreeView1.SelectedNode.Parent.Expand();
            }
        }

     //////////////////////////////////////////////////////////////////////////////////////////

    Hope this will help you

    Dont forget to mark as answer if this helps you

Page 1 of 1 (3 items)