mardi 12 avril 2016

show html elements based on user's role

I am trying to hide html elements from plain users such that only users. I have simple asp.net web form setup that makes use of roles provider and membership.

<li runat="server" id="li1" visible ='<%# HttpContext.Current.User.IsInRole("admin") %>'><a href="screeners.aspx"><span> Admin link</span></a></li>

I also am trying this without success:

<li runat="server" id="liAdminUsers" visible ='<%# isAdmin %>'><a  href="screeners.aspx"><span> The Hopper</span></a></li>

the code behind is:

public bool isAdmin =false;
            protected void Page_Load(object sender, EventArgs e)
            {

                isAdmin = Page.User.IsInRole("admin");
                       }




Aucun commentaire:

Enregistrer un commentaire