1.權限以menu表為準為動態
/// <summary> /// 畫面數據綁定 /// </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 Label(); 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 = "cbxMenuName" + menuDs.Tables[0].Rows[countRow]["MenuId"].ToString(); //模式為更新,綁定當前角色權限數據 if (model != "0") { //獲取更新RoleKey string RoleKey = ""; if (Request.QueryString["RoleKey"] != null) { RoleKey = Request.QueryString["RoleKey"].ToString(); } //獲取更新RoleKey數據 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.Add(cbxMenuName); row.Cells.Add(cell2); tbMenuIds.Rows.Add(row); } LOG.Debug("[Bind]執行結束。"); } catch (Exception ex) { LOG.Error(ex.Message); } }
2.彈出子畫面時候需要禁用父頁面,選用showModalDialog()
問題一:子畫面更新后關閉window.opener=null;window.close();無提示框彈出,會彈出一個新的頁面。
解決方案:在head標簽中追加<base target="_self"/>
問題二:子畫面二次進入時保存在緩存中,不走pageload,導致數據更新后沒有重新綁定動態checkbox。
解決方案:Response.Expires = -1; 給一個過期時間,重新刷新頁面。
問題三:子畫面DB更新后頁面關閉,父頁面無刷新保持舊數據。
解決過程1:window.location.reload(); 會刷新整個頁面,有如下提示。

解決過程2:window.location.href = window.location.href; IE完成刷新父頁面,但是火狐不兼容,彈不出showModalDialog。
解決過程3:window.location.replace(url);完成火狐和IE的父頁面刷新。
3.更新獲取前臺動態checkbox,checked的ID(數字部分對應的menuID)拼接字符串逗號隔開
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() + ","; } }新聞熱點
疑難解答