Front page:
<%@ Page language= "C #" autoeventwireup= "true" codebehind= "Default.aspx.cs" inherits= "Tree._default"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> directory tree </title>
<script type= "Text/javascript" language= "JavaScript" src= "Mztreeview10.js" ></script>
<link href= "Css/global.css" type= "Text/css" rel= "stylesheet"/>
<style type= "Text/css" >
A.mztreeview
{
font-size:9pt;
padding-left:3px;
}
</style>
<body>
<form id= "Form1" runat= "Server" >
<script type= "Text/javascript" language= "JavaScript" >
<!--
window.tree = new mztreeview ("Tree");
tree.icons["Property"] = "Property.gif";
tree.icons["CSS"] = "collection.gif";
tree.icons["book"] = "Book.gif";
tree.iconsexpand["book"] = "Bookopen.gif";
tree.seticonpath ("/images/");
<% loadtree (); %>
tree.seturl ("#");
tree.settarget ("");
document.write (tree.tostring ()); &NBSP
-->
</script>
</form>
< /body>
Background page:
Using System;
Using System.Data;
Using System.Configuration;
Using System.Collections;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using SYSTEM.DATA.SQL;
Using System.Data.SqlClient;
Using Treedemo.dbutility;
namespace Tree
{
public partial class _default:system.web.ui.page
{
public static string str;
protected void Page_Load (object sender, EventArgs e)
{
}
public void Loadtree ()
{
String sql = "Select Id,isnull (pid,0) as pid,caption from";
SqlDataReader dr = TreeDemo.DBUtility.SqlHelper.ExecuteReader (sqlhelper.connectionstring,commandtype.text, SQL, NULL);
string node = "";
while (Dr. Read ())
{
node = "\ r \ n tree.nodes[" + "\" + dr["PID"]. ToString () + "_" + dr["ID"]. ToString () + "\" "+"] = ";
node = node + "\" + "text:" + dr["Caption"]. ToString () + ";" + "\";
Response.Write (node);
}
if (!DR. isclosed)
Dr. Close ();
}
}
}