hi,
i am using a treeview control in asp.net 1.1. i have created a website where i have a treeview and when a user clicks on any node , the data is shown on the right. i have written code that the treeview is always in expanded mode. i have a situation that whenever a user clicks on the parent node, the parent node get collapsed and the get expanded. i would like the user to feel that the treeview control is not used on the page. i have used AUTOPOSTBACK = TRUE , SELECTEXPANDS = FALSE , SHOWPLUS = FALSE. i have tried using the COLLAPSE method also. it doesnot work.can u tell me how to avoid it.
please find the code below
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
TreeView1.TreeNodeSrc = "aaa.xml";
TreeView1.DataBind();
}
}
private void TreeView1_SelectedIndexChange(object sender, Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs e)
{
string sel;
sel = e.NewNode;
TreeSelLoadPage(sel);
}
private void LoadContent(string pageLoad)
{
string filename =pageLoad;
if(pageLoad.LastIndexOf('#')>0)
{
filename = pageLoad.Substring(0,pageLoad.LastIndexOf('#'));
}
if(File.Exists(Server.MapPath(filename)))
{
string showPage = "<script>document.getElementById('doc').src='" + pageLoad + "'</script>";
RegisterStartupScript("1",showPage);
}
}
private void TreeSelLoadPage(string nodeID)
{
TreeNode node = TreeView1.GetNodeFromIndex(nodeID);
// string strDir = Server.MapPath(node.NodeData.ToString());
string strDir = node.NodeData.ToString();
LoadContent(strDir);
}
private void ExpandAllNodes(TreeNode pNode)
{
pNode.Expanded = true;
if(pNode.Nodes.Count >0)
{
foreach(TreeNode tn in pNode.Nodes)
{
ExpandAllNodes(tn);
}
}
}
// code where the treeview is in expanded mode
private void EnSuite_PreRender(object sender, System.EventArgs e)
{
foreach (TreeNode tn in TreeView1.Nodes)
{
ExpandAllNodes(tn);
}
//TreeView1.ExpandLevel = 3;
}