隐藏<li> asp.net项目取决于用户权限

时间:2016-01-25 14:41:50

标签: c# asp.net list hide

当特定用户登录网站时,我必须隐藏第4列。这是我目前的asp和c#代码:

protected void Page_Load(object sender, EventArgs e)
        {
            ((LoggedIn)Page.Master).CurrentPage = LoggedIn.LoggedInMenuPages.1;

            if (CurrentCustomer.AdminRole==false)
            {
               ******NEED TO HIDE ITEM 4
            }
        }

1 个答案:

答案 0 :(得分:0)

runat="server"添加到元素以及特定ID,之后进入Page_LoadControlID.Visible=false

<强> ASPX

<li id="AdminElement" runat="server">
 //other tags
</li>

<强>的Page_Load

 AdminElement.Visible = CurrentCustomer.AdminRole;
 //remove the class attribute from the aspx
 AdminElement.Attributes["class"] = GetCurrentPageStyle("4");       
相关问题