Click here to Skip to main content
15,881,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Master Page in my Web Application. Now i am creating multiple content pages. there is one Div in the Master page which had label. Now i want to hide that Div in one content page and other requirement in other content page is to get label which is inside the Div.

So How to hide Div which is in Master Page, from Content Page and how to get label which is defined in that Div from Content page?
Posted

1 solution

You should be able to get a reference to the control object which is located in master page from your content page using syntax like this:


C#
HtmlGenericControl yourDiv = this.Master.FindControl("yourDiv") as HtmlGenericControl;
Label yourlbl = this.Master.FindControl("yourlbl") as Label;


However please note that to get a reference to your div control you should be having a runat="server" in the div declaration i.e., it is actually a server side html control.

Regards
Pawan
 
Share this answer
 
Comments
Dhritirao's 16-Feb-13 3:33am    
if (User.IsInRole("Resource"))
{
this.Master.FindControl("linksmenu").Visible = false;
this.Master.FindControl("linksmenu2").Visible = true;

}
else
{
this.Master.FindControl("linksmenu").Visible = true;
this.Master.FindControl("linksmenu2").Visible = false;
}
Dhritirao's 16-Feb-13 3:34am    
this is the code i found to hide the div but it is not working

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