Click here to Skip to main content
15,917,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
C#
//this was the code on content page......  
            Panel testimonial = (Panel)this.Master.FindControl("testimonial");
            testimonial.Visible = false;


//but this code is not working
Posted
Updated 7-Jan-13 0:44am
v4
Comments
OriginalGriff 7-Jan-13 6:36am    
And?
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...

If the ID of panel is Panel1, use
C#
Panel pl = (Panel)Master.FindControl("Panel1"); 
pl.Visible = false;
 
Share this answer
 
Comments
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....
Hi,

You can define a property in master page like :

C#
public bool TestPanelVisible
{
    set
    {
          pnlTest.Visible = value;
    }
    get
    {
          return pnlTest.Visible;
    }
}


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

C#
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 :)

Regards
Gayatri
 
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