Asp. NET permissions control for HTML page elements (iii)

Source: Internet
Author: User
Some things that were not considered in the previous blog This time change the code as follows:

Interface Front Desk:

<%@ page language= "C #" autoeventwireup= "true" codebehind= "AdmShowDIV.aspx.cs" inherits= " ExamSystemV3.Manager.RoleManager.AdmShowDIV "%> <! DOCTYPE html> 

Interface background:

Using the 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_lo Ad (object sender, EventArgs e) {string strlike= ""; IsPostBack) {//Binding interface Databindwindows (Strlike);}} <summary>///binding all interfaces///</summary>/<param name= "strlike" ></param> public void Databindwi Ndows (String strlike) {DataTable dt = new DataTable (); Admwindowsmanager Admwindowsmanager = new Admwindowsmanager (); Find out all the interface dt = Admwindowsmanager.querywindowinfo (strlike); Binding interface Information 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 (); Information to isolate the interface dt = Admwindowsmanager.querywindowinfo (strlike); String strwindowsid=ddlwindowsname.selectedvalue.tostring (). Trim (); Strlike = "id=" "+strwindowsid+" "; datarow[] Rows =dt. Select (Strlike); Get path string strurl = rows[0]["Windowsurl"]. ToString (); strURL = ". /.. /"+ strURL; frmwindows.attributes["src"]=strurl; frmupdatediv.attributes["src"] = "admupdatediv.aspx?" Windowsid= ' "+ strwindowsid +" ' ";}}}

JS:

var windowsid; function Windowsinfo () {//get ifrm var frmwindows = document.getElementById ("Frmwindows"). Contentwindow;//Get interface ID Windowsid = document.getElementById ("Ddlwindowsname"). Value; var rootboxs = frmWindows.document.getElementById ("main"); var child = Rootboxs.childnodes; Findchildbox (child); };  Search child node 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 = Findparen Tbox (Parentnode[i].parentnode); var parentboxid = parentbox.id; if (window. XMLHttpRequest) {//ie7 above,firefox,chrome^^ xmlhttp = new XMLHttpRequest ();//In order to be compatible with part of the Mozillar browser, when the response from the server starts with not XML, The resulting unresponsive problem 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 XMLHttpRequestObject "); }////Register callback function//xmlhttp.onreadystatechange = callback; Send Message Xmlhttp.open (' GET ', '. /.. /manager/rolemanager/addbox.ashx?childboxid= ' + childboxid + ' &childboxtitle= ' + childboxtitle + ' &parentboxId = ' + parentboxid+ ' &windowsid= ' +windowsid, true); Xmlhttp.send (NULL);  function callback () {////Determine if the interaction is complete, return correctly//if (xmlhttp.readystate = = 4 && xmlhttp.status = = 200) {//}//}} Findchildbox (Parentnode[i].childnodes)}}//Query parent node function Findparentbox (child) {if (Child.nodename = = "box") {return Child } else {return Findparentbox (Child.parentnode)}}

Generic handler:

Using System; Using System.Collections.Generic; Using System.Linq; Using System.Web; Using the BLL. MANAGER.ROLEUSERMANAGERBLL; Using System.Data; Using System.Text; Using Model; Using BLL;  namespace ExamSystemV3.Manager.RoleManager {//<summary>///Addbox Summary description///</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 (); Collect information 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 = "Yes"; String strdatetime = Publicbll.getdate (); String StrIP = Publicbll.getwebclientip (); String stroperator = "Xvshu";//context. session["Userno"]. ToString (). Trim ();; Assigning a value to an entity class ediv.id = Strchildboxid; Ediv.mainrelation = Strparentboxid; Ediv.divname = Strchildboxtitle; Ediv.divdescribe = Strchildboxtitle; Ediv.operator = Stroperator; Ediv.operatorip = StrIP; Ediv.state = strstate; Ediv.datetime = Strdatetime; Assign value Ewindowsdiv.divid = Strchildboxid to Windowsdiv entity class; Ewindowsdiv.windowsid = Strwindowsid; ewindowsdiv.isvisible = "Yes"; Ewindowsdiv.operator = Stroperator; Ewindowsdiv.operatorip = StrIP; Ewindowsdiv.datetime = Strdatetime; Add Div admdivmanager.adddiv (ediv,ewindowsdiv); } public bool IsReusable {get {return false;}}} }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.