当前位置: 移动技术网 > IT编程>开发语言>.net > ASP.NET对HTML页面元素进行权限控制(三)

ASP.NET对HTML页面元素进行权限控制(三)

2017年12月12日  | 移动技术网IT编程  | 我要评论

赵本山有几个孩子,拜错堂,隔壁家的山田君

上一篇博客中有些没有考虑到的东西这次更改一下代码如下:

界面前台:
复制代码 代码如下:

<%@ 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='"+strwindowsid+"'";
datarow[] rows =dt.select (strlike);
//获得路径
string strurl = rows[0]["windowsurl"].tostring ();
strurl = "../../" + strurl;
frmwindows.attributes["src"]=strurl;
frmupdatediv.attributes["src"] = "admupdatediv.aspx?windowsid='" + strwindowsid + "'";
}
}
}

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('text/xml');
}
}
else if (window.activexobject) {
//ie5\ie6
xmlhttp = new activexobject("microsoft.xmlhttp");
}
if (xmlhttp == null || xmlhttp == undefined) {
alert("con't create xmlhttprequest object");
}

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

xmlhttp.open('get', '../../manager/rolemanager/addbox.ashx?childboxid=' + childboxid + '&childboxtitle=' + childboxtitle + '&parentboxid=' + parentboxid+'&windowsid='+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)

}

}

一般处理程序:
复制代码 代码如下:

using system;
using system.collections.generic;
using system.linq;
using system.web;
using bll.manager.roleusermanagerbll;
using system.data;
using system.text;
using model;
using bll;

namespace examsystemv3.manager.rolemanager
{
/// <summary>
/// addbox 的摘要说明
/// </summary>
public class addbox : ihttphandler
{

public void processrequest(httpcontext context)
{
context.response.contenttype = "text/plain";
system.threading.thread.sleep(1000);
diventity ediv = new diventity();
tr_windowsdiventity ewindowsdiv = new tr_windowsdiventity();
admdivmanager admdivmanager = new admdivmanager();
publicbll publicbll = new publicbll();
///收集信息
string strchildboxid = "";
string strchildboxtitle = "";
strchildboxid = context.request.querystring["childboxid"].tostring().trim();
strchildboxtitle = context.server.urldecode(context.request.querystring["childboxtitle"].tostring().trim());
string strwindowsid = context.request.querystring["windowsid"].tostring().trim();
string strparentboxid=context.request.querystring["parentboxid"].tostring ().trim();;
string strstate = "是";
string strdatetime = publicbll.getdate();
string strip = publicbll.getwebclientip();
string stroperator ="xvshu";//context.session["userno"].tostring().trim(); ;

//给实体类赋值
ediv.id = strchildboxid;
ediv.mainrelation = strparentboxid;
ediv.divname = strchildboxtitle;
ediv.divdescribe = strchildboxtitle;
ediv.operator = stroperator;
ediv.operatorip = strip;
ediv.state = strstate;
ediv.datetime = strdatetime;
//给windowsdiv实体类赋值
ewindowsdiv.divid = strchildboxid;
ewindowsdiv.windowsid = strwindowsid;
ewindowsdiv.isvisible = "是";
ewindowsdiv.operator = stroperator;
ewindowsdiv.operatorip = strip;
ewindowsdiv.datetime = strdatetime;

//添加div
admdivmanager.adddiv(ediv,ewindowsdiv);

}

public bool isreusable
{
get
{
return false;
}
}
}
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网