類似 MSDN 導航樹效果 ASP.Net(C#) + JavaScript 實現! (轉)

worldblog發表於2008-01-31
類似 MSDN 導航樹效果 ASP.Net(C#) + JavaScript 實現! (轉)[@more@]

測試站點:
/tree/FORM1.x">

雖然號稱 了!
但實際還是傳統 CGI、ASP 的思想,沒有使用Codebehind="WebFORM1.aspx.cs",仍然採取了 B/S 混合(HTML/)指令碼的方式:





WebFORM1






















System.Data.Ole.OleDbConnection oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
oleDbConnection1.ConnectionString =@"Provr=OLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Test;Data =TRIATONPSQL2KE";
oleDbConnection1.ConnectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("/dvbbs") + @"Tree.mdb;Persist Security Info=False";
oleDbConnection1.Open();
System.Data.OleDb.OleDbCommand OleDbCommand1 = new System.Data.OleDb.OleDbCommand(" *,(select count(*) from tree where parentid = T.id) as children from tree T where id = id",oleDbConnection1) ;
System.Data.OleDb.OleDbDataReader OleDbDataReader1 = OleDbCommand1.ExecuteReader();
int i = 0;
while (OleDbDataReader1.Read())
{
 %>
               
          i++;
}

%>

















WebFORM2









string ParentNode;
ParentNode = Request.QueryString["pnode"];
//Response.Write(ParentNode.Replace("_",""));
int i;
int j;
string nSpace="";
j= ParentNode.Length - ParentNode.Replace("_","").Length;
for (i=0;i    nSpace = nSpace + "    ";
string sHTML ="";
i=0;
       System.Data.OleDb.OleDbConnection oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
oleDbConnection1.ConnectionString =@"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Test;Data Source=TRIATONPSQL2KE";
oleDbConnection1.ConnectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("/dvbbs") + @"Tree.mdb;Persist Security Info=False";
oleDbConnection1.Open();
System.Data.OleDb.OleDbCommand OleDbCommand1 = new System.Data.OleDb.OleDbCommand("select *,(select count(*) from tree where parentid =T.id ) as Children from tree T where parentid = " + Request.QueryString["PID"],oleDbConnection1) ;
System.Data.OleDb.OleDbDataReader OleDbDataReader1 = OleDbCommand1.ExecuteReader();
while (OleDbDataReader1.Read())
{
    sHTML = sHTML + "";
           if (System.Convert.ToInt64(OleDbDataReader1["children"])>0)
              sHTML = sHTML + "";
            i++;
}
Response.Write(sHTML);
%>



 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-998836/,如需轉載,請註明出處,否則將追究法律責任。

相關文章