Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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
Posted 7-Jan-13 1:31am
ntitish1.5K
Edited 7-Jan-13 1:44am
v4
Comments
OriginalGriff at 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 at 7-Jan-13 6:40am
   
sir it is not finding the control of the panel...
Rate this: bad
good
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;
  Permalink  
Comments
ntitish at 7-Jan-13 6:42am
   
its not working sir,even i tried that.......
Zafar Sultan at 7-Jan-13 6:45am
   
What's the error?
ntitish at 8-Jan-13 5:12am
   
it is unable to find the control sir
Zafar Sultan at 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 at 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 at 8-Jan-13 6:17am
   
Good you found the solution.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
You can define a property in master page like :
 
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 :
 
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 Smile | :)
 
Regards
Gayatri
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2014
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