Click here to Skip to main content
14,545,020 members
Rate this:
Please Sign up or sign in to vote.
See more:
on my master page there is one panel testimonial.but i dont want to display on my content page by finding control of the panel in content page and should be visible false.
//this was the code on content page......  
            Panel testimonial = (Panel)this.Master.FindControl("testimonial");
            testimonial.Visible = false;

//but this code is not working
Updated 7-Jan-13 0:44am
OriginalGriff 7-Jan-13 6:36am
Your question is what?
What is happening that shouldn't, or not happening that should?
Any error messages?
ntitish 7-Jan-13 6:40am
sir it is not finding the control of the panel...
Rate this:
Please Sign up or sign in to vote.

Solution 1

If the ID of panel is Panel1, use
Panel pl = (Panel)Master.FindControl("Panel1"); 
pl.Visible = false;
ntitish 7-Jan-13 6:42am
its not working sir,even i tried that.......
Zafar Sultan 7-Jan-13 6:45am
What's the error?
ntitish 8-Jan-13 5:12am
it is unable to find the control sir
Zafar Sultan 8-Jan-13 6:00am
What is the output you get when you put a breakpoint at: Panel pl = (Panel)Master.FindControl("Panel1");? What is pl? null?
ntitish 8-Jan-13 6:15am
i got it sir,on master page i should not give the alert panels visible should not give from content page only we have to manage....
Zafar Sultan 8-Jan-13 6:17am
Good you found the solution.
Rate this:
Please Sign up or sign in to vote.

Solution 2


You can define a property in master page like :

public bool TestPanelVisible
          pnlTest.Visible = value;
          return pnlTest.Visible;

And in content page you can set this property to true/false when you want to show/hide the panel as :

this.Master.TestPanelVisible = false;

In the content page you have to register Master using following tag:

<%@ MasterType VirtualPath="~/MasterPage.master" %>

Only then you will be able to access master page's property.

Hope this Helps :)


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

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