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
>
查看全文
相关阅读:
Mysql中limit的用法详解
EXCEPTION与ERROR的区别
调用sed命令的三种方式
学编程一定要上大学?美国一半码农都没有计算机学位
awk 循环语句例子
Ubuntu 16.04 LTS今日发布
Ubuntu启动eclipse问题
Vim技能修炼教程(6)
Vim技能修炼教程(7)
Vim技能修炼教程(5)
原文地址:https://www.cnblogs.com/goodspeed/p/35854.html
最新文章
RTSP拉流协议视频平台EasyNVR能够接入多少路视频直播流?
新版支持RTSP协议EasyNVR视频平台添加角色管理后调取接口注意事项
如何查看Linux系统运行RTSP协议EasyNVR视频平台端口被占用的进程?
RTSP协议视频平台EasyNVR无法探测到摄像头onvif,如何排查问题?
在阿里云中运行RTSP协议视频平台EasyNVR,该如何配置安全组?
CentOS系统下RTSP协议拉流视频平台EasyNVR端口如何穿透防火墙?
新版RTSP协议视频流媒体平台EasyNVR首页播放器遮挡下拉框的问题优化
Pandas模块:表计算与数据分析
NumPy:数组计算
IPython的简单介绍
热门文章
cookie和session
自定义Web框架
Http协议详细介绍
redis进阶
Redis数据类型之散列表
Redis数据类型之列表操作
redis介绍以及安装
Eclipse快捷键指南
MyBatis choose(when, otherwise)标签
多线程爬虫Miner
Copyright © 2011-2022 走看看