首頁 > 後端開發 > C#.Net教程 > ASP.NET對HTML頁面元素進行權限控制(三)

ASP.NET對HTML頁面元素進行權限控制(三)

高洛峰
發布: 2017-02-03 15:07:30
原創
1139 人瀏覽過

上一篇部落格有些沒有考慮到的東西這次更改一下程式碼如下: 

介面前台: 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AdmShowDIV.aspx.cs" Inherits="ExamSystemV3.Manager.RoleManager.AdmShowDIV" %> 

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="Author" content="kudychen@gmail.com" /> 
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
<title></title> 
<script src="../../js/DIV/jquery.js" type="text/javascript"></script> 
<script src="../../js/DIV/DIV.js" type="text/ecmascript"></script> 
<link href="../../css/admin.global.css" rel="stylesheet" type="text/css" /> 
<link href="../../css/admin.content.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="../../../js/jquery.easyui.min.js"></script> 
<script type="text/javascript" src="../../js/jquery-1.4.2.min.js"></script> 
<script type="text/javascript" src="../../js/jquery.utils.js"></script> 
<link href="../../jBox/Skins/Green/jbox.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="../../jBox/jquery.jBox-2.3.min.js"></script> 
<script type="text/javascript" src="../../js/admin.js"></script> 
<script type="text/javascript" src="../../js/SimpleTree.js"></script> 


</head> 
<body> 
<form id="form1" runat="server"> 
<div class="container"> 
<div class="location">当前位置:界面元素管理 -> 查看界面元素</div> 

<div class="blank10"></div> 

<div class="search block"> 
<div class="h"> 
<span class="icon-sprite icon-magnifier"></span> 
<h3>快速搜索</h3> 
</div> 
<div class="tl corner"></div><div class="tr corner"></div><div class="bl corner"></div><div class="br corner"></div> 
<div class="cnt-wp"> 
<div class="cnt"> 
<div class="search-bar" id="SelectRole"> 
<label class="txt-green">请选择界面:</label> 
<asp:DropDownList ID="DdlWindowsName" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DdlWindowsName_SelectedIndexChanged"> 
</asp:DropDownList> 
<a class="btn-lit" href="#" onclick="WindowsInfo()"><span>扫描界面信息</span></a> 
</div> 

</div> 
</div> 
</div> 
</div> 

<div class="block"> 
<div class="h"> 
<span class="icon-sprite icon-list"></span> 
<h3>界面详情</h3> 
</div> 
<div class="tl corner"></div> 
<div class="tr corner"></div> 
<div class="bl corner"></div> 
<div class="br corner"></div> 
<div class="cnt-wp"> 
<div class="cnt"> 
<iframe id="frmWindows" runat="server" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto" style=" display: inline; height: 400px;" width="75%" ></iframe> 
<iframe id="frmUpdateDIV" runat="server" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto" style="display: inline; height: 400px; width: 24%;"></iframe> 
</div> 

</div> 
</div> 

</form> 
</body> 
</html>
登入後複製

介面後台: 

using BLL.Manager.RoleUserManagerBLL; 
using System; 
using System.Collections.Generic; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 

namespace ExamSystemV3.Manager.RoleManager 
{ 
public partial class AdmShowDIV : System.Web.UI.Page 
{ 
protected void Page_Load(object sender, EventArgs e) 
{ 
string strLike=""; 
if (!IsPostBack) 
{ 
//绑定界面 
DataBindWindows(strLike); 
} 


} 
/// <summary> 
/// 绑定所有界面 
/// </summary> 
/// <param name="strLike"></param> 
public void DataBindWindows(string strLike) 
{ 
DataTable dt = new DataTable(); 
AdmWindowsManager admWindowsManager = new AdmWindowsManager(); 
//查出所有的界面 
dt = admWindowsManager.QueryWindowInfo(strLike); 
//绑定界面信息 
DdlWindowsName.DataSource = dt; 
DdlWindowsName.DataValueField = "Id"; 
DdlWindowsName.DataTextField = "WindowsName"; 
DdlWindowsName.DataBind(); 

} 

protected void DdlWindowsName_SelectedIndexChanged(object sender, EventArgs e) 
{ 
DataTable dt = new DataTable(); 
string strLike = ""; 
AdmWindowsManager admWindowsManager = new AdmWindowsManager(); 
//查出界面的信息 
dt = admWindowsManager.QueryWindowInfo(strLike); 
string strWindowsId=DdlWindowsName.SelectedValue.ToString().Trim(); 
strLike = "Id=&#39;"+strWindowsId+"&#39;"; 
DataRow[] rows =dt.Select (strLike); 
//获得路径 
string strURL = rows[0]["WindowsURL"].ToString (); 
strURL = "../../" + strURL; 
frmWindows.Attributes["src"]=strURL; 
frmUpdateDIV.Attributes["src"] = "AdmUpdateDIV.aspx?WindowsID=&#39;" + strWindowsId + "&#39;"; 
} 
} 
}
登入後複製

JS: 

var WindowsID; 
function WindowsInfo() { 
//获取ifrm 
var frmWindows = document.getElementById("frmWindows").contentWindow; 
//获取界面ID 
WindowsID = document.getElementById("DdlWindowsName").value; 

var rootboxs = frmWindows.document.getElementById("main"); 
var child = rootboxs.childNodes; 
findchildbox(child); 


}; 
//搜寻子节点 
function findchildbox(parentNode) { 

for (var i = 0; i < parentNode.length; i++) { 

if (parentNode[i].nodeName == "BOX") { 

var childboxId = parentNode[i].id; 
var childboxTitle = encodeURI(parentNode[i].title); 
var parentbox = findparentbox(parentNode[i].parentNode); 
var parentboxId = parentbox.id; 
if (window.XMLHttpRequest) { 
//IE7 above,firefox,chrome^^ 
xmlhttp = new XMLHttpRequest(); 
//为了兼容部分Mozillar浏览器,当来自服务器响应开头不是xml,导致的无法响应问题 
if (xmlhttp.overrideMimeType) { 
xmlhttp.overrideMimeType(&#39;text/xml&#39;); 
} 
} 
else if (window.ActiveXObject) { 
//IE5\IE6 
xmlhttp = new activeXObject("Microsoft.XMLHTTP"); 
} 
if (xmlhttp == null || xmlhttp == undefined) { 
alert("con&#39;t create XMLHttpRequest Object"); 
} 

////注册回调函数 
//xmlhttp.onreadystatechange = callback; 
//发送信息 

xmlhttp.open(&#39;GET&#39;, &#39;../../Manager/RoleManager/AddBox.ashx?childboxId=&#39; + childboxId + &#39;&childboxTitle=&#39; + childboxTitle + &#39;&parentboxId=&#39; + parentboxId+&#39;&windowsId=&#39;+WindowsID, true); 
xmlhttp.send(null); 


//function callback() { 
// //判断交互是否完成,是否正确返回 
// if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 

// } 
//} 

} 

findchildbox(parentNode[i].childNodes) 

} 

} 

//查询父节点 
function findparentbox(child) { 

if (child.nodeName == "BOX") { 
return child; 
} else { 
return findparentbox(child.parentNode) 

} 

}
登入後複製

rrASP對HTML頁面元素進行權限控制(三)相關文章請注意PHP中文網!

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板