zoukankan
html css js c++ java
Asp.net 2.0 Treeview 无限级无刷新示例
<%
@ Page Language
=
"
C#
"
%>
<%
@ Import Namespace
=
"
System.IO
"
%>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
>
<
script
runat
="server"
>
void
Treeview1_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
if
(IsCallback)
if
(e.Node.ChildNodes.Count
==
0
)
{
LoadChildNode(e.Node);
}
}
private
void
LoadChildNode(TreeNode node)
{
DirectoryInfo directory;
directory
=
new
DirectoryInfo(node.Value);
foreach (DirectoryInfo sub
in
directory.GetDirectories())
{
TreeNode subNode
=
new
TreeNode(sub.Name);
subNode.Value
=
sub.FullName;
try
{
if
(sub.GetDirectories().Length
>
0
||
sub.GetFiles().Length
>
0
)
{
subNode.SelectAction
=
TreeNodeSelectAction.SelectExpand;
subNode.PopulateOnDemand
=
true
;
subNode.NavigateUrl
=
"
#
"
;
}
}
catch
{ subNode.ImageUrl
=
"
WebResource.axd?a=s&r=TreeView_XP_Explorer_ParentNode.gif&t=632242003305625000
"
; }
node.ChildNodes.Add(subNode);
}
foreach (FileInfo fi
in
directory.GetFiles())
{
TreeNode subNode
=
new
TreeNode(fi.Name);
node.ChildNodes.Add(subNode);
}
}
</
script
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
runat
="server"
>
<
title
>
Untitled Page
</
title
>
</
head
>
<
body
bgcolor
="white"
>
<
form
id
="form1"
runat
="server"
>
<
div
>
<
asp:treeview
ID
="Treeview1"
runat
="server"
ImageSet
="XPFileExplorer"
AutoGenerateDataBindings
="false"
ExpandDepth
=0
OnTreeNodePopulate
="Treeview1_TreeNodePopulate"
>
<
SelectedNodeStyle
BackColor
="#B5B5B5"
></
SelectedNodeStyle
>
<
Nodes
>
<
asp:TreeNode
Value
="C:"
Text
="C:"
PopulateOnDemand
="true"
SelectAction
="Select"
NavigateUrl
="#"
>
</
asp:TreeNode
>
</
Nodes
>
<
NodeStyle
VerticalPadding
="2"
Font-Names
="Tahoma"
Font-Size
="8pt"
HorizontalPadding
="2"
ForeColor
="Black"
></
NodeStyle
>
<
HoverNodeStyle
Font-Underline
="True"
ForeColor
="#6666AA"
></
HoverNodeStyle
>
</
asp:treeview
>
</
div
>
</
form
>
</
body
>
</
html
>
查看全文
相关阅读:
命令模式(Command Pattern)
外观模式(Facade Pattern)
Hash函数的安全性
单向散列函数
装饰者模式(Decorator Pattern)
尝试设计LFSR加密器,并用CAP4验证随机性
对称密码-流密码
组合模式(Composite Pattern)
桥接模式(Bridge Pattern)
适配器模式(Adapter Pattern)
原文地址:https://www.cnblogs.com/goodspeed/p/35854.html
最新文章
synchronized
SpringMVC实现客户端跳转
SpringMVC接受表单数据
eclipse及idea使用问题记录(为了方便github同步,重新用Markdown写了一篇)
SpringMVC 注解方式进行配置页面跳转
SpringMVC修改视图定位
SpringMVC的工作原理
创建SpringMVC项目
MVC笔记
使用hexo+github搭建博客
热门文章
克隆数组
Array
数组的扩展
数值的扩展
正则表达式的扩展
JavaScript正则表达式RegExp对象
JavaScript正则表达式RegExp对象方法
变量的解构赋值
字符串类的扩展
Utilities
Copyright © 2011-2022 走看看