简单高效的asp.net目录树源代码_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > 简单高效的asp.net目录树源代码

简单高效的asp.net目录树源代码

 2014/8/22 16:23:13  Ranran  程序员俱乐部  我要评论(0)
  • 摘要:前台页面:<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="Tree._Default"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http
  • 标签:.net ASP.NET 目录 net 代码
前台页面:

<%@ 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">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>目录树</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>
</head>
<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());
    -->
    </script>
    </form>
</body>
</html>
后台页面:
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 Tree order by ID";
            SqlDataReader dr = Treewww.tydsyy.comDemo.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();
        }
    }
}

 

发表评论
用户名: 匿名