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
>
查看全文
相关阅读:
Form组件
LAMP+Varnish的实现
缓存反向代理-Varnish
CDN初识
HTTP缓存初探
Keepalived搭建主从架构、主主架构实例
实现高可用-Keepalived
nginx负载均衡实例
lvs集群实现lvs-dr模型和lvs-nat模型
LVS介绍
原文地址:https://www.cnblogs.com/goodspeed/p/35854.html
最新文章
python-pymysql防止sql注入攻击介绍
mysql-数据备份与存储过程
mysql-表关系介绍(应用较多)
mysql-多表联查(实例)
mysql-数据库查询语句汇总
mysql-配置与使用(跳过原始密码登陆)
Python爬虫11-XML与XPath概述及lxml库的应用
Python爬虫10-页面解析数据提取思路方法与简单正则应用
Python爬虫9-request包介绍及应用
Python爬虫8-ajax爬取豆瓣影榜
热门文章
Python爬虫7-Cookie & Session
nginx.conf and dockerfile带颜色
nginx+uWSGI+django+virtualenv+superviso发布web服务器
Centos安装python3
virtualenvwrapper
Flask_入门
CMDB连接方式
DRF
git基本操作
mysql配置文件
Copyright © 2011-2022 走看看