Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends please help me

i have a master page with Default page.
there are six buttons on master page.i want to invisible button 4 on the page .
so how i can do this work please help me and give me some articles ..

i want to know this solutions friends please help me again ......faiz
Posted

Use this code with your own button id

C#
(this.Page.Master.FindControl("btnRegister") as Button).Visible=false;
 
Share this answer
 
try:
C#
Button myButton = (Button) Master.FindControl("buttonId");
if(myButton != null)
{
    myButton .Visible =false;
}
 
Share this answer
 
The best way to do this would be to have a public property on the master page. this property can change the visibility of the controls and you can use this property from child pages conditionally.

see this example:
in my master page i have (RightSide is name of a Panel in my master page)

C#
   public bool SidePaneVisibility
   {
   get
   {
    return RightSide.Visible;
   }
   set
   {
      RightSide.Visible = value;
   }
}

and I am using it from my content page conditionally as:

C#
if (Session["UserId"] == null)
          {
              MasterPage master = (MasterPage)this.Master;
              master.SidePaneVisibility = false;
          }
 
Share this answer
 
If you need to understand the concepts then read this once: Beginner's Tutorial on Master Pages in ASP.NET[^]
 
Share this answer
 
Have a look at the following article. It shows you how to access the MasterPage from content pages:

http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx[^]
 
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