这个asp页面是由下面这个页面调用出来的:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>阿赖目录树控件应用示例--动态加载树前台页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script src="alai_tree.js" language="JavaScript"></script>
</head>
<body>
<script language="JavaScript">
var images=new alai_imagelist()
images.path="images/"
images.add("folderclose","folder")
images.add("hfile","file")
images.add("face")
images.add("angry")
images.add("plus_m","expand")
images.add("plus_top","expand_top")
images.add("plus_end","expand_end")
images.add("minus_m","collapse")
images.add("minus_top","collapse_top")
images.add("minus_end","collapse_end")
images.add("branch","leaf")
images.add("branch_end","twig")
images.add("vline","line")
images.add("blank")
var tree=new alai_tree(images,0)tree.onexpand=function(srcNode)
{
if(srcNode.first.label.innerText=="loading...")
{
//动态加载子节点的代码:
ifrLoad.location="tree_load.asp?id="+srcNode.getKey().replace("n","");
}
return true;
}
</script>
<iframe id="ifrLoad" style="width:0;height:0" src="tree_load.asp?id=-1"></iframe>
</body>
</html>
<html>
<head>
<title>阿赖目录树控件应用示例--动态加载树前台页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script src="alai_tree.js" language="JavaScript"></script>
</head>
<body>
<script language="JavaScript">
var images=new alai_imagelist()
images.path="images/"
images.add("folderclose","folder")
images.add("hfile","file")
images.add("face")
images.add("angry")
images.add("plus_m","expand")
images.add("plus_top","expand_top")
images.add("plus_end","expand_end")
images.add("minus_m","collapse")
images.add("minus_top","collapse_top")
images.add("minus_end","collapse_end")
images.add("branch","leaf")
images.add("branch_end","twig")
images.add("vline","line")
images.add("blank")
var tree=new alai_tree(images,0)tree.onexpand=function(srcNode)
{
if(srcNode.first.label.innerText=="loading...")
{
//动态加载子节点的代码:
ifrLoad.location="tree_load.asp?id="+srcNode.getKey().replace("n","");
}
return true;
}
</script>
<iframe id="ifrLoad" style="width:0;height:0" src="tree_load.asp?id=-1"></iframe>
</body>
</html>
<%@ page import ="java.util.*"%>
<%@ page import ="java.io.*"%>
<%@ page import="java.text.*"%>
<html>
<head>
<title>阿赖目录树控件示例--ASP后台加载程序</title>
</head><body><%
String parentid=request.getParameter("id");
String strurl="jdbc:odbc:driver={MicrosoftAccessDriver(*.mdb)};DBQ=tree.mdb";try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch (ClassNotFoundException e) {
out.print ("驱动程序不存在");
}
try{
Connection odbcconn = DriverManager.getConnection(strurl);
Statement odbcstmt = odbcconn.createStatement();
String odbcQuery="select * ,(select count(*) from tree where parentid=subTree.id) as childNum from tree subTree where parentid=" + parentid ;
ResultSet odbcrs=odbcstmt.executeQuery(odbcQuery);
out.print("<script>");
out.print("var tree=self.parent.tree;")
//加载第一级节点时,应设id为-1
if (parentid.equals("-1"))
out.print("var toNode=tree.root;");
else
//节点的键值已依次设成n1,n2,n3........
out.print("var toNode=tree.nodes['n" + parentid + "'];");while (odbcrs.next()) {
//如果icon字段不为空,图标取数据库的值,否则根据是否有子节点取"folder"或"file"。相应地imagelist应提供这两个键值的图标
if(odbcrs.getString("icon").equals(""))
icon=odbcrs.getString("icon");
else {
if(odbcrs.getInt("childNum")==0)
icon="file" ;
else
icon="folder" ;
} //输出添加节点的代码,第三个参数是设键值的
out.print("var nNode=tree.add(toNode,'last','" + odbcrs.getString("text") + "','" + "n" + odbcrs.getString("id") + "','" + icon + "','" + odbcrs.getString("exeCategory") + "','" + odbcrs.getString("exeArgv") + "');");
out.print("if(nNode.parent.first.label.innerText=='loading...')nNode.parent.first.remove();"); if(odbcrs.getInt("childNum")!=0)
out.print("nNode.add('loading...');nNode.expand(false);");
}out.print("</script>");
%>
<p align="center">copywrite by 赖国欣 2003/7 All right reserved</p>
<p align="center">Email: <a href="mailto:[email protected]">[email protected]</a> website:
<a href="http://www.9499.net">http://www.9499.net</a></p>
</body>
</html>