Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Masterpage
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
good
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.
 
Regards
Pawan
  Permalink  
Comments
nakshatra 2013 at 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; }
nakshatra 2013 at 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
0 Sergey Alexandrovich Kryukov 529
1 OriginalGriff 297
2 Damith Weerasinghe 295
3 ravikhoda 250
4 thatraja 210
0 Sergey Alexandrovich Kryukov 10,974
1 OriginalGriff 6,667
2 Peter Leow 4,760
3 Abhinav S 3,813
4 Maciej Los 3,565


Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 16 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid