Click here to Skip to main content
15,904,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a html button in Master Page without id & having a function onclick.
I want to hide it in Content page,I tried the following but I still get an error.

C#
protected void Page_PreInit(object sender, EventArgs e)
   {
              HtmlButton btn1 = (HtmlButton)Master.FindControl("btn1");
           btn1.Visible= false;


Please help me to solve this.

Thanks in Advance.
Posted
Updated 9-Jun-11 22:52pm
v2
Comments
RakeshMeena 10-Jun-11 4:12am    
What error you got?
[no name] 10-Jun-11 4:53am    
Any Error?
Sergey Alexandrovich Kryukov 10-Jun-11 18:22pm    
Tag it: "ASP.NET". Is it not?
--SA

1 solution

Hi First you need to create property in Master page like
C#
public buttonstate 
{
  set {btn1.Visible = value;}
  get {btn1.Visible;}
}

Now you need to use in Content page like

C#
Master.buttonstate = false;

Note: you may get syntax error, because i have directly type here..

Thanks;
 
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