hiding buttons in master page

Posted by pankaj on Stack Overflow See other posts from Stack Overflow or by pankaj
Published on 2010-03-03T08:49:40Z Indexed on 2010/04/05 11:33 UTC
Read the original article Hit count: 260

Filed under:

Hi,

I am working on an app where i am having some linkbuttons in master page.  

I want to display them depending upon the authorization given to them once they logs in. I have initially made all of them visible false and then i am checking the authorisation in the aspx.cs class of master page. I make the link button visible depending upon the right granted to the user. But it is making all the link buttons visible. Instead it should only make two of them visible and rest should be hidden. Following is my code from MasterPage.aspx.cs:

ArrayList arrlstUserRoles = new ArrayList();
                arrlstUserRoles = (ArrayList)Session["Roles"];
                for (int j = 0; j < arrlstUserRoles.Count; j++)
                {
                    if (int.Parse(arrlstUserRoles[j].ToString()) == 1)
                    {
                        lbtnRetailer.Visible = true;
                    }
                    else if (int.Parse(arrlstUserRoles[j].ToString()) == 2)
                    {
                        lbtnCategory.Visible = true;
                    }
                    else if (int.Parse(arrlstUserRoles[j].ToString()) == 3)
                    {
                        lbtnCouponTemplate.Visible = true;
                    }
                    else if (int.Parse(arrlstUserRoles[j].ToString()) == 4)
                    {
                        //lbtnStoreManagement.Visible = true;
                    }
                    else if (int.Parse(arrlstUserRoles[j].ToString()) == 5)
                    {
                        lbtnStoreManagement.Visible = true;
                    }
                    else if (int.Parse(arrlstUserRoles[j].ToString()) == 6)
                    {
                        lbtnContentManagement.Visible = true;
                    }
                    else if (int.Parse(arrlstUserRoles[j].ToString()) == 7)
                    {
                        //lbtnStoreManagement.Visible = true;
                    }
                }  

© Stack Overflow or respective owner

Related posts about masterpage