当前位置: 编程技术>.net/c#/asp.net
ASP.NET对HTML页面元素进行权限控制(三)
来源: 互联网 发布时间:2014-08-25
本文导语: 上一篇博客中有些没有考虑到的东西这次更改一下代码如下: 界面前台: 代码如下: 当前位置:界面元素管理 -> 查看界面元素 快速搜索 请选择界面: 扫描界面信息 界面详情 界面...
上一篇博客中有些没有考虑到的东西这次更改一下代码如下:
界面前台:
快速搜索
界面详情
界面后台:
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);
}
}
///
/// 绑定所有界面
///
///
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) {
//IE5IE6
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
{
///
/// AddBox 的摘要说明
///
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;
}
}
}
}
界面前台:
代码如下:
当前位置:界面元素管理 -> 查看界面元素
快速搜索
界面详情
界面后台:
代码如下:
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);
}
}
///
/// 绑定所有界面
///
///
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) {
//IE5IE6
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
{
///
/// AddBox 的摘要说明
///
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;
}
}
}
}