Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have created a menu under <div> tag using <ul><li>'s in master page and i want it to be displayed only to Admin and not to Users ...How can i achieve this ...Can anyone please help me out...?

Thanks in advance
Posted

add a web confing file to the folder that contains Master Page and enable the follwing on the web config file. also enable role manager to true
XML
<authorization>
     <allow roles="Administrators" />
     <deny users="*" />
</authorization>

create an admin link like so:

and then in code write this:
protected void Page_Load(object sender, EventArgs e)
{
if (HttpContext.Current.User.IsInRole("Administrator"))
{
adminLink.Visible = true;
}
}
 
Share this answer
 
v4
Comments
Arjun Holla 16-May-14 8:08am    
Can u Plz Let me know clearly...?I want my div tag(Menus) to be hidden for users when they enter the page and it has to show when admin enters the same page...
Arjun Holla 19-May-14 2:33am    
Thank you for the help...I solved it by using

this.Page.Master.FindControl("Menu1").Visible = false;

Thank You
Can u Plz Let me know clearly...?I want my div tag(Menus) to be hidden for users when they enter the page and it has to show when admin enters the same page...
 
Share this answer
 
I solved by using
if(Role=="User")
{
this.Page.Master.FindControl("Menu1").Visible = false;
}
else
{
this.Page.Master.FindControl("Menu1").Visible = true;
}

Thank you
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900