Click here to Skip to main content
15,888,202 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to know that hot to render control on master page according to login


For example I have a master page Access.Master which has four image control so I want to show two out of four according to login of user means according to role.
Posted

Yes you can do it. In your child page add this code
Image ImageDashBoardIcon = (Image)this.Master.FindControl("Your Image ID");

Do the required process according to your role.
 
Share this answer
 
v2
You can set the visible property to false, like so:

<asp:Image ID="imageName" runat="server" Visible="false" ImageUrl="yourURL"/>


Then in your MasterPage.cs set visible if in role:

C#
if (HttpContext.Current.User.IsInRole("Admin"))
{
    imageName.Visible = true;
}
else
{
    imageName.Visible = false;
}


This is the easiest approach to me.
 
Share this answer
 

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