search
HomeBackend DevelopmentC#.Net TutorialASP.NET controls permissions on HTML page elements (3)

There are some things that were not considered in the previous blog. This time, change the code as follows:

Interface frontend:

<%@ 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 id="快速搜索">快速搜索</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 id="界面详情">界面详情</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>

Interface backend:

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) 

} 

}

General processing procedures:

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; 
} 
} 
} 
}

For more ASP.NET permission control on HTML page elements (3), please pay attention to the PHP Chinese website for related articles!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to use char array in C languageHow to use char array in C languageApr 03, 2025 pm 03:24 PM

The char array stores character sequences in C language and is declared as char array_name[size]. The access element is passed through the subscript operator, and the element ends with the null terminator '\0', which represents the end point of the string. The C language provides a variety of string manipulation functions, such as strlen(), strcpy(), strcat() and strcmp().

What is the role of char in C stringsWhat is the role of char in C stringsApr 03, 2025 pm 03:15 PM

In C, the char type is used in strings: 1. Store a single character; 2. Use an array to represent a string and end with a null terminator; 3. Operate through a string operation function; 4. Read or output a string from the keyboard.

How to handle special characters in C languageHow to handle special characters in C languageApr 03, 2025 pm 03:18 PM

In C language, special characters are processed through escape sequences, such as: \n represents line breaks. \t means tab character. Use escape sequences or character constants to represent special characters, such as char c = '\n'. Note that the backslash needs to be escaped twice. Different platforms and compilers may have different escape sequences, please consult the documentation.

How to use various symbols in C languageHow to use various symbols in C languageApr 03, 2025 pm 04:48 PM

The usage methods of symbols in C language cover arithmetic, assignment, conditions, logic, bit operators, etc. Arithmetic operators are used for basic mathematical operations, assignment operators are used for assignment and addition, subtraction, multiplication and division assignment, condition operators are used for different operations according to conditions, logical operators are used for logical operations, bit operators are used for bit-level operations, and special constants are used to represent null pointers, end-of-file markers, and non-numeric values.

The difference between multithreading and asynchronous c#The difference between multithreading and asynchronous c#Apr 03, 2025 pm 02:57 PM

The difference between multithreading and asynchronous is that multithreading executes multiple threads at the same time, while asynchronously performs operations without blocking the current thread. Multithreading is used for compute-intensive tasks, while asynchronously is used for user interaction. The advantage of multi-threading is to improve computing performance, while the advantage of asynchronous is to not block UI threads. Choosing multithreading or asynchronous depends on the nature of the task: Computation-intensive tasks use multithreading, tasks that interact with external resources and need to keep UI responsiveness use asynchronous.

How to convert char in C languageHow to convert char in C languageApr 03, 2025 pm 03:21 PM

In C language, char type conversion can be directly converted to another type by: casting: using casting characters. Automatic type conversion: When one type of data can accommodate another type of value, the compiler automatically converts it.

What is the function of C language sum?What is the function of C language sum?Apr 03, 2025 pm 02:21 PM

There is no built-in sum function in C language, so it needs to be written by yourself. Sum can be achieved by traversing the array and accumulating elements: Loop version: Sum is calculated using for loop and array length. Pointer version: Use pointers to point to array elements, and efficient summing is achieved through self-increment pointers. Dynamically allocate array version: Dynamically allocate arrays and manage memory yourself, ensuring that allocated memory is freed to prevent memory leaks.

Avoid errors caused by default in C switch statementsAvoid errors caused by default in C switch statementsApr 03, 2025 pm 03:45 PM

A strategy to avoid errors caused by default in C switch statements: use enums instead of constants, limiting the value of the case statement to a valid member of the enum. Use fallthrough in the last case statement to let the program continue to execute the following code. For switch statements without fallthrough, always add a default statement for error handling or provide default behavior.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools