protected void Page_Load(object sender, EventArgs e) { switch (Request.QueryString["ShowPanel"]) { case "DetailsPanel": Page.ClientScript.RegisterStartupScript(this.GetType(), "showTabs", "GoToTab(1);", true); break; case "ViewPanel": Page.ClientScript.RegisterStartupScript(this.GetType(), "showTabs", "GoToTab(2);", true); break; } // Role Based Page Access // // START // Session["EditLinkButton"] = "True"; Session["DeleteLinkButton"] = "True"; string[] pageurl = Path.GetFileName(Request.Url.AbsolutePath).Split('.'); string page = pageurl[0]; UserBL userBL = new UserBL(); string pageaccess = userBL.PageAccess(page); string functionname = ""; string functionaccess = ""; string createpage = ""; string viewpage = ""; string cpermission = ""; string vpermission = ""; string[] pid = { "" }; pid = pageaccess.Split(':'); for (int x = 0; x < pid.Length; x++) { string[] fid = { "" }; fid = pid[x].Split('#'); if (fid.Length > 0 && fid[0] != "") { functionname = fid[0]; functionaccess = fid[1]; if (functionname == "Search" && functionaccess == "False") { Panel search = (Panel)BodyContent.FindControl("SearchPanel"); search.Visible = false; } else if (functionname == "List" && functionaccess == "False") { Panel list = (Panel)BodyContent.FindControl("ListPanel"); list.Visible = false; //Panel mini = (Panel)BodyContent.FindControl("MiniDetailsPanel"); //mini.Visible = false; //Panel more = (Panel)BodyContent.FindControl("MiniDetailMorePanel"); //more.Visible = false; } else if (functionname == "Edit" && functionaccess == "False") { LinkButton edit = (LinkButton)BodyContent.FindControl("EditLinkButton"); edit.Visible = false; Session["EditLinkButton"] = "False"; } else if (functionname == "Delete" && functionaccess == "False") { LinkButton delete = (LinkButton)BodyContent.FindControl("DeleteLinkButton"); delete.Visible = false; Session["DeleteLinkButton"] = "False"; } else if (functionname == "Create" && functionaccess == "False") { createpage = "Create"; cpermission = "False"; Panel create = (Panel)BodyContent.FindControl("DetailsPanel"); create.Visible = false; } else if (functionname == "View" && functionaccess == "False") { viewpage = "View"; vpermission = "False"; Panel view = (Panel)BodyContent.FindControl("ViewPanel"); view.Visible = false; } }//if }//for // if a user do not have any permission it will take to the dashboard page. if ((viewpage == "View" && vpermission == "False") && (createpage == "Create" && cpermission == "False")) { Response.Redirect("~/Dashboard/Dashboard.aspx"); } //for left panel Contact + Task + Document + Administrator String[] pages = {"Contacts","Tasks","Documents"}; for (int i = 0; i < 3; i++) { string ps = userBL.PageAccess(pages[i]); if ((ps.Contains("Create#False")) && (ps.Contains("View#False")) && i == 0) { contact.Visible = false; } if ((ps.Contains("Create#False")) && (ps.Contains("View#False")) && i == 1) { task.Visible = false; } if ((ps.Contains("Create#False")) && (ps.Contains("View#False")) && i == 2) { documents.Visible = false; } } string isadmin = Convert.ToString(Session["IsAdmin"]); if (isadmin !="True") { administrator.Visible = false; } // END // }