A permission-based popup image. The permission-based popup image is maintained.

Source: Internet
Author: User

A permission-based popup image. The permission-based popup image is maintained.

1. the permission is dynamic based on the menu table

/// <Summary> /// Bind the image data /// </summary> protected void Bind () {try {LOG. Debug ("[Bind. "); String strRoleKey =" "; string strRoleName =" "; string strMenuIds =" "; string [] MenuId; Sys_MenuBusiness bllSysMenu = new Sys_MenuBusiness (); dataSet menuDs = new DataSet (); menuDs = bllSysMenu. getMenuList (); for (int countRow = 0; countRow <menuDs. tables [0]. rows. count; countRow ++) {TableRow row = new TableRow (); // label TableCell cell1; cell1 = new TableCell (); Label lblMenuName = new Labe L (); lblMenuName. ID = "lblMenuName" + countRow. toString (); lblMenuName. attributes. add ("Name", "lblMenuName" + countRow. toString (); lblMenuName. text = menuDs. tables [0]. rows [countRow] ["MenuName"]. toString (); lblMenuName. font. size = 9; cell1.Controls. add (lblMenuName); row. cells. add (cell1); // checkbox TableCell cell2; cell2 = new TableCell (); CheckBox cbxMenuName = new CheckBox (); cbxMenuName. ID = "c BxMenuName "+ menuDs. Tables [0]. Rows [countRow] [" MenuId "]. ToString (); // The mode is updated and the current role permission data is bound if (model! = "0") {// obtain the updated RoleKey string RoleKey = ""; if (Request. QueryString ["RoleKey"]! = Null) {RoleKey = Request. queryString ["RoleKey"]. toString () ;}// obtain the updated RoleKey data Sys_RoleBusiness bll = new Sys_RoleBusiness (); DataSet ds = new DataSet (); ds = bll. getKeyRoleList (RoleKey); strRoleKey = ds. tables [0]. rows [0] ["RoleKey"]. toString (); strRoleName = ds. tables [0]. rows [0] ["RoleName"]. toString (); strMenuIds = ds. tables [0]. rows [0] ["MenuIds"]. toString (); if (ds. tables [0]. rows [0] ["IsActivity"]. ToString (). toUpper () = "TRUE") {ddlIsActivity. selectedValue = "1";} else {ddlIsActivity. selectedValue = "0";} MenuId = strMenuIds. split (','); hidRoleKey. value = strRoleKey; txtRoleName. text = strRoleName; for (int count = 0; count <MenuId. length; count ++) {if (menuDs. tables [0]. rows [countRow] ["MenuId"]. toString () = MenuId [count]) {cbxMenuName. checked = true; break ;}} cell2.Controls. ad D (cbxMenuName); row. Cells. Add (cell2); tbMenuIds. Rows. Add (row);} LOG. Debug ("[Bind] execution ends. ");} Catch (Exception ex) {LOG. Error (ex. Message );}}

 

2. Disable the parent page when the sub-screen is displayed. Select showModalDialog ()

Problem 1: After the sub-screen is updated, close window. opener = null; window. close (); if no prompt box is displayed, a new page is displayed.

Solution: add the <base target = "_ self"/>

Problem 2: when the sub-screen enters the cache again, it is saved without pageload. As a result, the dynamic checkbox is not re-bound after the data is updated.

Solution: Response. Expires =-1; give an expiration time and refresh the page.

Problem 3: After the sub-screen DB is updated, the page is closed, and the parent page does not refresh the old data.

Solution 1: window. location. reload (); refresh the entire page with the following prompt.

 

Solution 2: window. location. href = window. location. href; IE refresh the parent page, but Firefox is incompatible and cannot display showModalDialog.

Solution 3: window. location. replace (url); refresh the parent page of Firefox and IE.

3. Update and obtain the front-end dynamic checkbox. The checked ID (the menuID corresponding to the number) is separated by commas (,).

                string strMenuIds = "";                Sys_MenuBusiness bll = new Sys_MenuBusiness();                DataSet menuDs = new DataSet();                menuDs = bll.GetMenuList();                for (int count = 0; count < menuDs.Tables[0].Rows.Count; count++)                {                    string check = Request.Form["cbxMenuName" + menuDs.Tables[0].Rows[count]["MenuId"].ToString()];                    if (check == "on")                    {                        strMenuIds = strMenuIds + menuDs.Tables[0].Rows[count]["MenuId"].ToString() + ",";                    }                }

 

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.