Click here to Skip to main content
13,046,045 members (46,094 online)
Rate this:
Please Sign up or sign in to vote.
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 15-Feb-13 21:11pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:

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.

nakshatra 2013 16-Feb-13 3:33am
if (User.IsInRole("Resource"))
this.Master.FindControl("linksmenu").Visible = false;
this.Master.FindControl("linksmenu2").Visible = true;

this.Master.FindControl("linksmenu").Visible = true;
this.Master.FindControl("linksmenu2").Visible = false;
nakshatra 2013 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 16 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100