Ajax
Using the Ajaxpro frame, the feeling is still relatively easy to use. More in line with their own habits, the whole code is not difficult. is implemented using CSS.
The computer on the home can not install Ms SQL, simply use MySQL. On the way to learn the use of MySQL function.
Want to use the XDJM can leave a message here. Thank you
database:
ysql> CREATE TABLE category (
-> CategoryID int,
-> CategoryName varchar (m),
-> fatherid int);
DELIMITER//
mysql> Create function isleaf (cat_id int)
& nbsp; -> returns int
-> begin
-> declare count int;
-> Select COUNT (*) into the count from category where fatherid=cat_id;
-> If count = 0 Then
-> return 1
->;
-> End If;
-> return 0;
-> end;
->//
mysql> INSERT INTO category values (1, ' My documen
->;
Query OK, 1 row affected (0.08 sec)
Mysql> INSERT into category values (2, ' ASP. NET ', 1
->;
Query OK, 1 row affected (0.02 sec)
Mysql> INSERT into category values (3, ' JAVA ', 1)
->;
Query OK, 1 row affected (0.03 sec)
Mysql> INSERT into category values (4, ' C # ', 1)
->;
Query OK, 1 row affected (0.04 sec)
Mysql> INSERT into category values (5, ' HTML ', 1)
->;
Query OK, 1 row affected (0.01 sec)
Mysql> INSERT into category values (6, ' Oracle ', 1)
->;
Query OK, 1 row affected (0.02 sec)
Mysql> INSERT into category values (7, ' line ', 1)
->;
Query OK, 1 row affected (0.02 sec)
Tree.aspx
<%@ Page language= "C #" autoeventwireup= "true" codefile= "Tree.aspx.cs" inherits= "Tree"%>
Tree
Ajax-based dynamic tree menu
Tree.aspx.cs
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 Ajaxpro;
Using MySql.Data.MySqlClient;
public partial class Tree:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
Utility.registertypeforajax (typeof (tree));
}
Private Random rand = new Random ();
[Ajaxmethod ()]
Public DataSet getsubcategory (int Icategoryid)
{
DataSet ds = new DataSet ();
Mysqlconnection conn = new Mysqlconnection ("Server=127.0.0.1;uid=root ;p wd=111111;database=test ");
Mysqlcommand cmd = conn. CreateCommand ();
Cmd.commandtext = string. Format ("Select CategoryID, CategoryName, Fatherid, IsLeaf (CategoryID) as IsChild from Category WHERE Fatherid = {0}", ICat Egoryid);
mysqldataadapter da = new Mysqldataadapter (cmd);
Try
{
Da. Fill (DS);
}
catch (Mysqlexception)
{
}
Finally
{
Conn. Close ();
}
System.Threading.Thread.Sleep (+ rand). Next (1000));
Console.WriteLine (ds. Tables[0]. Rows.Count.ToString ());
return DS;
}
[Ajaxmethod ()]
Public DataSet getdocinfo (int Icategoryid)
{
DataSet ds = new DataSet ();
return DS;
}
[Ajaxmethod ()]
Public DataSet getdocinfoincategory (int Icategoryid)
{
DataSet ds = new DataSet ();
Mysqlconnection conn = new Mysqlconnection ("Server=127.0.0.1;uid=root ;p wd=111111;database=test ");
Mysqlcommand cmd = conn. CreateCommand ();
Cmd.commandtext = string. Format (
"Select CategoryID, CategoryName, Fatherid from Category WHERE Fatherid = {0} and IsLeaf (CategoryID) = 1 ", Icategoryid);
mysqldataadapter da = new Mysqldataadapter (cmd);
Try
{
Da. Fill (DS);
}
catch (Mysqlexception)
{
}
Finally
{
Conn. Close ();
}
return DS;
}
}
Css
A
{
Text-decoration:none;
}
a,a:visited
{
Color: #000;
Background:inherit;
}
Body
{
margin:0;
padding:20px;
font:12px Tahoma, XXFarEastFont-Arial, Sans-serif;
}
Dt
{
font-size:22px;
Font-weight:bold;
margin:0 0 0 15px;
}
Dd
{
margin:0 0 0 15px;
}
H4
{
margin:0;
padding:0;
font-size:18px;
Text-align:center;
}
P
{
margin:0;
padding:0 0 0 18px;
}
P A,p a:visited
{
Color: #00f;
Background:inherit;
}
. Treemenu Img.s
{
Cursor:hand;
Vertical-align:middle;
}
. Treemenu ul
{
padding:0;
}
. Treemenu Li
{
List-style:none;
padding:0;
}
. Closed ul
{
Display:none;
}
. Child IMG.S
{
Background:none;
Cursor:default;
}
#CategoryTree ul
{
margin:0 0 0 17px;
}
#CategoryTree Img.s
{
width:34px;
height:18px;
}
#CategoryTree. Opened Img.s
{
Background:url (skin3/opened.gif) no-repeat 0 1px;
}
#CategoryTree. Closed Img.s
{
Background:url (skin3/closed.gif) no-repeat 0 1px;
}
#CategoryTree. Child IMG.S
{
Background:url (skin3/child.gif) no-repeat 13px 2px;
}
#CategoryTree
{
Float:left;
width:249px;
border:1px solid #99BEEF;
Background: #D2E4FC;
Color:inherit;
margin:3px;
padding:3px;
}