我在加栽的时候只加载其下一级节点,结果的那树就认为下级节点就是叶节点了 根本就不是点展开那个图标!
解决方案 »
- 使用table控件如何加超链接?
- 【】asp.net调用外部dll,出问题???
- [转贴] 生成 WEB 后台管理
- 简单的问题, 我能否在某下操作后先弹出个对话框,然后转向另外个页面
- 怎么写接口
- web控件问题
- 如何在按下“提交”按钮之后提交当前窗体数据并重定向到另一页?
- datagrid送分问题,无数据时怎么让它的大小也保持原型,谢
- 要写毕业论文了,大家帮忙给介绍几个查资料的好地方?
- asp.net视频播放怎么获取id并根据ID获取路径path
- 求救!!!!!!!!!!!!!!!!!!!!!!在考试!!!!!!!!!!!!!!!!!!!!!!!答案一有就送分呀!
- 那位大侠发《精通ASP.NET 2.0网络应用系统开发》的光盘代码比我!100分相送!
<%@ Page Language="C#" Theme="Default" %>
<%@ Import Namespace="System.IO" %><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Populating TreeView Nodes On-Demand</title>
</head>
<script language="C#" runat="server"> static readonly char[] _slashArray = new char[] {'/'};
void PopulateNode(Object source, TreeNodeEventArgs e)
{
TreeNode node = e.Node;
if (node.Value == "Demos")
node.Value = "~/"; String rootDirectory = Request.MapPath("~/", Request.ApplicationPath, false);
String fullPath = Request.MapPath(node.Value, Request.ApplicationPath, false);
if (fullPath.StartsWith(rootDirectory) == false)
{
// Mitigate against spoofed callback arguments
// Requested directory is not under root directory
return;
} String[] dirs = Directory.GetDirectories(fullPath); // Enumerate directories
foreach (String dir in dirs)
{
String virtualDir = node.Value.TrimEnd(_slashArray) + "/" + Path.GetFileName(dir); TreeNode newNode = new TreeNode(Path.GetFileName(dir), virtualDir);
if (Directory.GetFiles(dir).Length > 0
|| Directory.GetDirectories(dir).Length > 0)
{
newNode.PopulateOnDemand = true;
}
node.ChildNodes.Add(newNode);
} // Enumerate files
String[] files = Directory.GetFiles(fullPath);
foreach (String file in files)
{
TreeNode newNode = new TreeNode(Path.GetFileName(file), Path.GetFileName(file));
node.ChildNodes.Add(newNode);
}
} </script>
<body>
<div>
<h2>Populating TreeView Nodes On-Demand</h2> <form action="treeview10_ondemand_cs.aspx" runat="server"> <asp:TreeView ID="MyTree" SkinID="Explorer" PathSeparator="|" OnTreeNodePopulate="PopulateNode"
ExpandDepth="1" runat="server">
<Nodes>
<asp:TreeNode Text="Demos" PopulateOnDemand="true" />
</Nodes>
</asp:TreeView> </form>
</div>
</body>
</html>