ASP.NETはHTMLページ要素に対して権限制御を行う(三)
12892 ワード
前回のブログでは考えられなかったことがありましたが、今回コードを変更すると以下のようになります.
インタフェースのフロント:
インタフェースのフロント:
<br/><script src="../../js/DIV/jquery.js" type="text/javascript"/>
<br/><script src="../../js/DIV/DIV.js" type="text/ecmascript"/>
<br/><link href="../../css/admin.global.css" rel="stylesheet" type="text/css"/>
<br/><link href="../../css/admin.content.css" rel="stylesheet" type="text/css"/>
<br/><script type="text/javascript" src="../../../js/jquery.easyui.min.js"/>
<br/><script type="text/javascript" src="../../js/jquery-1.4.2.min.js"/>
<br/><script type="text/javascript" src="../../js/jquery.utils.js"/>
<br/><link href="../../jBox/Skins/Green/jbox.css" rel="stylesheet" type="text/css"/>
<br/><script type="text/javascript" src="../../jBox/jquery.jBox-2.3.min.js"/>
<br/><script type="text/javascript" src="../../js/admin.js"/>
<br/><script type="text/javascript" src="../../js/SimpleTree.js"/>
<br/>
<br/>
<br/>
<br/>
<br/><form id="form1" runat="server">
<br/><div class="container">
<br/><div class="location"> : -> </div>
<br/>
<br/><div class="blank10"/>
<br/>
<br/><div class="search block">
<br/><div class="h">
<br/><span class="icon-sprite icon-magnifier"/>
<br/><h3> </h3>
<br/></div>
<br/><div class="tl corner"/><div class="tr corner"/><div class="bl corner"/><div class="br corner"/>
<br/><div class="cnt-wp">
<br/><div class="cnt">
<br/><div class="search-bar" id="SelectRole">
<br/><label class="txt-green"> :</label>
<br/><dropdownlist id="DdlWindowsName" runat="server" autopostback="True" onselectedindexchanged="DdlWindowsName_SelectedIndexChanged">
<br/></dropdownlist>
<br/><a class="btn-lit" href="#" onclick="WindowsInfo()"><span> </span></a>
<br/></div>
<br/>
<br/></div>
<br/></div>
<br/></div>
<br/></div>
<br/>
<br/><div class="block">
<br/><div class="h">
<br/><span class="icon-sprite icon-list"/>
<br/><h3> </h3>
<br/></div>
<br/><div class="tl corner"/>
<br/><div class="tr corner"/>
<br/><div class="bl corner"/>
<br/><div class="br corner"/>
<br/><div class="cnt-wp">
<br/><div class="cnt">
<br/><iframe id="frmWindows" runat="server" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto" style=" display: inline; height: 400px;" width="75%"/>
<br/><iframe id="frmUpdateDIV" runat="server" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto" style="display: inline; height: 400px; width: 24%;"/>
<br/></div>
<br/>
<br/></div>
<br/></div>
<br/>
<br/></form>
<br/>
<br/>
<br/>
</code></pre>
<br/> :
<br/>
<pre><code>
<br/>using BLL.Manager.RoleUserManagerBLL;
<br/>using System;
<br/>using System.Collections.Generic;
<br/>using System.Data;
<br/>using System.Linq;
<br/>using System.Web;
<br/>using System.Web.UI;
<br/>using System.Web.UI.WebControls;
<br/>
<br/>namespace ExamSystemV3.Manager.RoleManager
<br/>{
<br/>public partial class AdmShowDIV : System.Web.UI.Page
<br/>{
<br/>protected void Page_Load(object sender, EventArgs e)
<br/>{
<br/>string strLike="";
<br/>if (!IsPostBack)
<br/>{
<br/>//
<br/>DataBindWindows(strLike);
<br/>}
<br/>
<br/>
<br/>}
<br/>/// <summary>
<br/>///
<br/>/// </summary>
<br/>/// <param name="strLike"/>
<br/>public void DataBindWindows(string strLike)
<br/>{
<br/>DataTable dt = new DataTable();
<br/>AdmWindowsManager admWindowsManager = new AdmWindowsManager();
<br/>//
<br/>dt = admWindowsManager.QueryWindowInfo(strLike);
<br/>//
<br/>DdlWindowsName.DataSource = dt;
<br/>DdlWindowsName.DataValueField = "Id";
<br/>DdlWindowsName.DataTextField = "WindowsName";
<br/>DdlWindowsName.DataBind();
<br/>
<br/>}
<br/>
<br/>protected void DdlWindowsName_SelectedIndexChanged(object sender, EventArgs e)
<br/>{
<br/>DataTable dt = new DataTable();
<br/>string strLike = "";
<br/>AdmWindowsManager admWindowsManager = new AdmWindowsManager();
<br/>//
<br/>dt = admWindowsManager.QueryWindowInfo(strLike);
<br/>string strWindowsId=DdlWindowsName.SelectedValue.ToString().Trim();
<br/>strLike = "Id='"+strWindowsId+"'";
<br/>DataRow[] rows =dt.Select (strLike);
<br/>//
<br/>string strURL = rows[0]["WindowsURL"].ToString ();
<br/>strURL = "../../" + strURL;
<br/>frmWindows.Attributes["src"]=strURL;
<br/>frmUpdateDIV.Attributes["src"] = "AdmUpdateDIV.aspx?WindowsID='" + strWindowsId + "'";
<br/>}
<br/>}
<br/>}
<br/>
</code></pre>
<br/>JS:
<br/>
<pre><code>
<br/>var WindowsID;
<br/>function WindowsInfo() {
<br/>// ifrm
<br/>var frmWindows = document.getElementById("frmWindows").contentWindow;
<br/>// ID
<br/>WindowsID = document.getElementById("DdlWindowsName").value;
<br/>
<br/>var rootboxs = frmWindows.document.getElementById("main");
<br/>var child = rootboxs.childNodes;
<br/>findchildbox(child);
<br/>
<br/>
<br/>};
<br/>//
<br/>function findchildbox(parentNode) {
<br/>
<br/>for (var i = 0; i < parentNode.length; i++) {
<br/>
<br/>if (parentNode[i].nodeName == "BOX") {
<br/>
<br/>var childboxId = parentNode[i].id;
<br/>var childboxTitle = encodeURI(parentNode[i].title);
<br/>var parentbox = findparentbox(parentNode[i].parentNode);
<br/>var parentboxId = parentbox.id;
<br/>if (window.XMLHttpRequest) {
<br/>//IE7 above,firefox,chrome^^
<br/>xmlhttp = new XMLHttpRequest();
<br/>// Mozillar , xml,
<br/>if (xmlhttp.overrideMimeType) {
<br/>xmlhttp.overrideMimeType('text/xml');
<br/>}
<br/>}
<br/>else if (window.ActiveXObject) {
<br/>//IE5\IE6
<br/>xmlhttp = new activeXObject("Microsoft.XMLHTTP");
<br/>}
<br/>if (xmlhttp == null || xmlhttp == undefined) {
<br/>alert("con't create XMLHttpRequest Object");
<br/>}
<br/>
<br/>////
<br/>//xmlhttp.onreadystatechange = callback;
<br/>//
<br/>
<br/>xmlhttp.open('GET', '../../Manager/RoleManager/AddBox.ashx?childboxId=' + childboxId + '&childboxTitle=' + childboxTitle + '&parentboxId=' + parentboxId+'&windowsId='+WindowsID, true);
<br/>xmlhttp.send(null);
<br/>
<br/>
<br/>//function callback() {
<br/>// // ,
<br/>// if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
<br/>
<br/>// }
<br/>//}
<br/>
<br/>}
<br/>
<br/>findchildbox(parentNode[i].childNodes)
<br/>
<br/>}
<br/>
<br/>}
<br/>
<br/>//
<br/>function findparentbox(child) {
<br/>
<br/>if (child.nodeName == "BOX") {
<br/>return child;
<br/>} else {
<br/>return findparentbox(child.parentNode)
<br/>
<br/>}
<br/>
<br/>}
<br/>
</code></pre>
<br/> :
<br/>
<pre><code>
<br/>using System;
<br/>using System.Collections.Generic;
<br/>using System.Linq;
<br/>using System.Web;
<br/>using BLL.Manager.RoleUserManagerBLL;
<br/>using System.Data;
<br/>using System.Text;
<br/>using Model;
<br/>using BLL;
<br/>
<br/>namespace ExamSystemV3.Manager.RoleManager
<br/>{
<br/>/// <summary>
<br/>/// AddBox
<br/>/// </summary>
<br/>public class AddBox : IHttpHandler
<br/>{
<br/>
<br/>public void ProcessRequest(HttpContext context)
<br/>{
<br/>context.Response.ContentType = "text/plain";
<br/>System.Threading.Thread.Sleep(1000);
<br/>DIVEntity EDiv = new DIVEntity();
<br/>TR_WindowsDIVEntity EWindowsDiv = new TR_WindowsDIVEntity();
<br/>AdmDIVManager admDIVManager = new AdmDIVManager();
<br/>PublicBLL publicBll = new PublicBLL();
<br/>///
<br/>string strChildBoxId = "";
<br/>string strChildBoxTitle = "";
<br/>strChildBoxId = context.Request.QueryString["childboxId"].ToString().Trim();
<br/>strChildBoxTitle = context.Server.UrlDecode(context.Request.QueryString["childboxTitle"].ToString().Trim());
<br/>string strWindowsId = context.Request.QueryString["windowsId"].ToString().Trim();
<br/>string strParentBoxId=context.Request.QueryString["parentboxId"].ToString ().Trim();;
<br/>string strState = " ";
<br/>string strDateTime = publicBll.GetDate();
<br/>string strIP = publicBll.GetWebClientIp();
<br/>string strOperator ="xvshu";//context.Session["UserNo"].ToString().Trim(); ;
<br/>
<br/>//
<br/>EDiv.Id = strChildBoxId;
<br/>EDiv.MainRelation = strParentBoxId;
<br/>EDiv.DIVName = strChildBoxTitle;
<br/>EDiv.DIVDescribe = strChildBoxTitle;
<br/>EDiv.Operator = strOperator;
<br/>EDiv.OperatorIP = strIP;
<br/>EDiv.State = strState;
<br/>EDiv.DateTime = strDateTime;
<br/>// WindowsDIV
<br/>EWindowsDiv.DIVID = strChildBoxId;
<br/>EWindowsDiv.WindowsID = strWindowsId;
<br/>EWindowsDiv.IsVisible = " ";
<br/>EWindowsDiv.Operator = strOperator;
<br/>EWindowsDiv.OperatorIP = strIP;
<br/>EWindowsDiv.DateTime = strDateTime;
<br/>
<br/>// DIV
<br/>admDIVManager.AddDIV(EDiv,EWindowsDiv);
<br/>
<br/>}
<br/>
<br/>public bool IsReusable
<br/>{
<br/>get
<br/>{
<br/>return false;
<br/>}
<br/>}
<br/>}
<br/>}
<br/>
</code></pre>
<div class="clearfix">
<span id="art_bot" class="jbTestPos"/>
</div>
</div>
</div>
</div>