1. Create an ASPX page
HTML code
<title> Hill </title>
<link type= "Text/css" href= ". /.. /styles/tree_css/tree.css "rel=" stylesheet ">
<body>
<form id= "Form1" runat= "Server" >
<table width=100% cellpadding=0 cellspacing=0 border=0>
<colgroup>
<col width=180/>
<col/>
</colgroup>
<tr>
<td>
<div class= "Treemenu" id= "CategoryTree" style= "width:100%"; Height:489px ">
</div>
</td>
<td>
<iframe id=furl height=20 style= "HEIGHT:497PX; width:100%; " ></iframe>
</td>
</tr>
</table>
<script language= "JScript" >
function El (ID)
{
return document.getElementById (ID);
}
function Expandsubcategory (Icategoryid)
{
var li_father = El ("li_" + Icategoryid);
if (li_father.getelementsbytagname ("Li"). Length > 0)//category downloaded
{
Changestatus (Icategoryid);
Return
}
Li_father.classname = "Opened";
Switchnote (Icategoryid, true);
Ajaxmethod.getsubcategory (Icategoryid, getsubcategory_callback);
}
function Getsubcategory_callback (response)
{
var dt = response.value.tables[0];
if (dt. Rows.length > 0)
{
var Icategoryid = dt. Rows[0]. Fatherid;
}
var li_father = El ("li_" + Icategoryid);
var ul = document.createelement ("ul");
for (var i = 0;i < dt. rows.length;i++)
{
if (dt. Rows[i]. IsChild = = 1)//leaf node
{
var li = document.createelement ("Li");
Li.classname = "Child";
Li.id = "Li_" + dt. Rows[i]. CategoryID;
var img = document.createelement ("img");
img.id = dt. Rows[i]. CategoryID;
Img.classname = "S";
IMG.SRC = ".. /.. /styles/tree_css/s.gif ";
var a = document.createelement ("a");
var id = dt. Rows[i]. CategoryID;
A.onmouseover = function ()
{
Previewimage (ID);
};
A.href = "Javascript:opendocument" (' "+ dt.) Rows[i]. CategoryID + "');";
a.innerhtml = dt. Rows[i]. CategoryName;
}
Else
{
var li = document.createelement ("Li");
Li.classname = "Closed";
Li.id = "Li_" + dt. Rows[i]. CategoryID;
var img = document.createelement ("img");
img.id = dt. Rows[i]. CategoryID;
Img.classname = "S";
IMG.SRC = ".. /.. /styles/tree_css/s.gif ";
Img.onclick = function () {
Expandsubcategory (this.id);
};
Img.alt = "expand/collapse";
var a = document.createelement ("a");
A.href = "Javascript:expandsubcategory (" +
Dt. Rows[i]. CategoryID + ");";
a.innerhtml = dt. Rows[i]. CategoryName;
}
Li.appendchild (IMG);
Li.appendchild (a);
Ul.appendchild (LI);
}
Li_father.appendchild (UL);
Switchnote (Icategoryid, false);
}
Click response function for leaf node
function OpenDocument (Icategoryid)
{
Pre-loading information
Preloadformurl (Icategoryid);
}
function Previewimage (Icategoryid)
{
}
function Changestatus (Icategoryid)
{
var li_father = El ("li_" + Icategoryid);
if (Li_father.classname = = "Closed")
{
Li_father.classname = "Opened";
}
Else
{
Li_father.classname = "Closed";
}
}
function Switchnote (Icategoryid, show)
{
var li_father = El ("li_" + Icategoryid);
if (show)
{
var ul = document.createelement ("ul");
Ul.id = "Ul_note_" + Icategoryid;
var note = document.createelement ("Li");
Note.classname = "Child";
var img = document.createelement ("img");
Img.classname = "S";
IMG.SRC = ".. /.. /styles/tree_css/s.gif ";
var a = document.createelement ("a");
A.href = "javascript:void (0);";
a.innerhtml = "Please wait";
Note.appendchild (IMG);
Note.appendchild (a);
Ul.appendchild (note);
Li_father.appendchild (UL);
}
Else
{
var ul = El ("Ul_note_" + Icategoryid);
IF (UL)
{
Li_father.removechild (UL);
}
}
}
Load root node
var tree = El ("CategoryTree");
var root = document.createelement ("Li");
Root.id = "Li_0";
Tree.appendchild (root);
Show first level category when loading page
Expandsubcategory (0);
function Preloadformurl (Icategoryid)
{
Get information about a picture using a synchronous call
var ds = Ajaxmethod.getformslist (Icategoryid). value;
If the result is returned
if (DS)
{
To determine whether a datasheet is not empty
if (ds. Tables[0]. Rows.length > 0)
{
The returned information datasheet
DT = ds. Tables[0];
El ("Furl"). src = dt. Rows[0]. Formurl;
}
else//Category not
{
}
}
}
</script>
</form>
</body>