0

Hi Guys

I am created a tree view in a usercontrol..and used it in master page.

But when i access the pages inside the parent node.the treeview is coming back to normal form.

but i want the parent node to be expanded until i am using pages from that section.

can any body please help me how to do that..

My code in user control is ..


thanks

public partial class leftmenu : System.Web.UI.UserControl
{
    private string sectionName;
    private TreeNode currentNode;
    private TreeNode parentNode;
    public MasterPage Masterpage;

    protected void Page_Load(object sender, EventArgs e)
        {

        }
        public void SetSectionName(string name)
        {
            sectionName = name;
        }
        private void CheckSelectedNodes(TreeNodeCollection nodes, string selected)
        {
            foreach (TreeNode node in nodes)
            {
                //Response.Write(node.Text + " = " + selected + " and " + node.NavigateUrl + "<br />");

                if (node.Text == selected)
                {
                    currentNode = node;
                    if (node.Parent != null)
                    {
                        parentNode = node.Parent;
                    }
                    return;


                }
                node.Expand();
                CheckSelectedNodes(node.ChildNodes, selected);
                node.Expand();
            }
        }
       //// public EazyShop.Admin.Master MasterPage
       // //{
       //     get { return (EazyShop.Admin.Master)Page.Master; }
       // }
        protected void LeftSiteMap_DataBound(object sender, EventArgs e)
        {

            CheckSelectedNodes(LeftSiteMap.Nodes, sectionName);
            LeftSiteMap.Nodes[0].Expand();
            if (currentNode != null)
            {
                currentNode.Selected = true;
                currentNode.ExpandAll();
            }
            if (parentNode != null) parentNode.Expand();
        }

         private void CheckSelectedNodes2(TreeNodeCollection nodes, string selected)
        {
            foreach (TreeNode node in nodes)
            {
                if (node.Text == selected)
                {
                    currentNode = node;
                    currentNode.Parent.Expand();
                }

            }
         }
        }

Edited by jas05: n/a

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by Ramesh S
0

1. Store the information about Selected/Expanded Node in Session.
2. On Page load event, extend the appropriat node after binding

Also visit this link.

A solution is given in the above link. But the tree node collection are stored in the Session. You can check if it addresses you problem.

Edited by Ramesh S: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.