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();
}
}
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();
}
}