人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

用ASP+XML完成CSDN的菜單(數據庫),可分權限管理.

用ASP+XML完成CSDN的菜單(數據庫),可分權限管理.

更新時間:2022-06-29 文章作者:未知 信息來源:網絡 閱讀次數:

我在開發公司OA系統的時候.想找一個CSDN的菜單.可是網上有這樣的代碼.可是不是基于數據庫,也不能按權限管理.我就寫了一個.我的這個.只有一個程序文件和一個數據庫.文件很少,也很容易查錯.但是功能完全實現了!

數據庫結構:

Table:Menu
ID
parentid,int,4
MenuName,Char,20
Link,Char,50

Table:UserLevel
ID
UserID,int,4
MenuID,int,4

-------------------------------------程序源文件:MenuList.Asp------------------------------

<%
'-------------------------------'
'源創商務策劃有限公司-OA系統
'模塊名稱:可權限控制的菜單
'-------------------------------'

set conn = Server.CreateObject("ADODB.Connection")
conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.mappath("tree.mdb")+";Persist Security Info=False")
%>

<HTML>
<HEAD>
<TITLE> DSTree </TITLE>
<style>
body,td{font:12px verdana}
#treeBox{background-color:#fffffa;}
#treeBox .ec{margin:0 5 0 5;}
#treeBox .hasItems{font-weight:bold;height:20px;padding:3 6 0 6;margin:2px;cursor:hand;color:#555555;border:1px solid #fffffa;}
#treeBox .Items{height:20px;padding:3 6 0 6;margin:1px;cursor:hand;color:#555555;border:1px solid #fffffa;}
</style>

<script>
//code by star 20003-4-7
var HC = "color:#990000;border:1px solid #cccccc";
var SC = "background-color:#efefef;border:1px solid #cccccc;color:#000000;";
var IO = null;
function initTree(){
var rootn = document.all.menuXML.documentElement;
var sd = 0;
document.onselectstart = function(){return false;}
document.all.treeBox.appendChild(createTree(rootn,sd));
}
function createTree(thisn,sd){
var nodeObj = document.createElement("span");
var upobj = document.createElement("span");
with(upobj){
style.marginLeft = sd*10;
className = thisn.hasChildNodes()?"hasItems":"Items";
innerHTML = "<img src=http://cfan.net.cn/info/expand.gif class=ec>" + thisn.getAttribute("text") +"";

onmousedown = function(){
if(event.button != 1) return;
if(this.getAttribute("cn")){
this.setAttribute("open",!this.getAttribute("open"));
this.cn.style.display = this.getAttribute("open")?"inline":"none";
this.all.tags("img")[0].src = this.getAttribute("open")?"http://cfan.net.cn/info/expand.gif":"contract.gif";
}
if(IO){
IO.runtimeStyle.cssText = "";
IO.setAttribute("selected",false);
}
IO = this;
this.setAttribute("selected",true);
this.runtimeStyle.cssText = SC;
}
onmouseover = function(){
if(this.getAttribute("selected"))return;
this.runtimeStyle.cssText = HC;
}
onmouseout = function(){
if(this.getAttribute("selected"))return;
this.runtimeStyle.cssText = "";
}
oncontextmenu = contextMenuHandle;
onclick = clickHandle;
}

if(thisn.getAttribute("treeId") != null){
upobj.setAttribute("treeId",thisn.getAttribute("treeId"));
}
if(thisn.getAttribute("href") != null){
upobj.setAttribute("href",thisn.getAttribute("href"));
}
if(thisn.getAttribute("target") != null){
upobj.setAttribute("target",thisn.getAttribute("target"));
}

nodeObj.appendChild(upobj);
nodeObj.insertAdjacentHTML("beforeEnd","<br>")

if(thisn.hasChildNodes()){
var i;
var nodes = thisn.childNodes;
var cn = document.createElement("span");
upobj.setAttribute("cn",cn);
if(thisn.getAttribute("open") != null){
upobj.setAttribute("open",(thisn.getAttribute("open")=="true"));
upobj.getAttribute("cn").style.display = upobj.getAttribute("open")?"inline":"none";
if( !upobj.getAttribute("open"))upobj.all.tags("img")[0].src ="contract.gif";
}

for(i=0;i<nodes.length;cn.appendChild(createTree(nodes[i++],sd+1)));
nodeObj.appendChild(cn);
}
else{
upobj.all.tags("img")[0].src ="endnode.gif";
}
return nodeObj;
}
window.onload = initTree;
</script>

<script>
function clickHandle(){
if((this.getAttribute("href")!=null)&&(this.getAttribute("href")!="http://"))
{parent.mainFrame.location.href=this.getAttribute("href");} //在MainFrame窗口打開連接。
}

function contextMenuHandle(){
event.returnValue = false;
var treeId = this.getAttribute("treeId");
// your code here
}
</script>
</HEAD>
<BODY>
<xml id=menuXML>
<?xml version="1.0" encoding="GB2312"?>
<DSTreeRoot text="系統菜單" open="true" treeId="123">

<%

Set rs = Conn.Execute("SELECT (select count(*) from Menu where Menu.parentid=x.id and Menu.ID in (SELECT UserLevel.menuid FROM UserLevel WHERE UserLevel.userid = 1)) AS children, * FROM Menu AS x WHERE x.id in (SELECT UserLevel.menuid FROM UserLevel WHERE UserLevel.userid = 1)")

Do while not rs.eof
if rs("ParentID")=0 then
Count = Rs ("children")
%>
<DSTree text="<%=rs("Content")%>" href="<%=rs("Link")%>" open="false" treeId="<%=rs("ID")%>">
<%
rs.MoveNext
end if

for i=1 to Count
%>
<DSTree text="<%=rs("Content")%>" href="<%=rs("Link")%>" open="false" treeId="<%=rs("ID")%>">
</DSTree>
<%
Rs.MoveNext
Next
Response.write("</DSTree>")
Loop


rs.close
Conn.close
Set rs = Nothing
Set Conn = Nothing
%>

</DSTreeRoot>
</xml>
<table style="position:absolute;left:0;top:0;">
<tr><td id=treeBox style="width:400px;height:200px;border:1px solid #cccccc;padding:5 3 3 5;" valign=top></td></tr>

</BODY>
</HTML>

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 饶平县| 吴川市| 宁晋县| 天水市| 大同县| 固始县| 苗栗县| 汝南县| 嘉兴市| 鄂伦春自治旗| 洞口县| 临泉县| 巴林右旗| 灵台县| 龙门县| 兴山县| 凤山市| 翁源县| 藁城市| 荔浦县| 万源市| 邯郸县| 克什克腾旗| 涿鹿县| 任丘市| 达尔| 深州市| 离岛区| 沭阳县| 枣庄市| 安阳县| 綦江县| 浪卡子县| 辽阳县| 绥江县| 雷波县| 泸西县| 湛江市| 新竹县| 泸溪县| 闵行区|