trying to hide a panel of Master Page in my content page using the following code
Panel p = this.Master.FindControl("panel1") as Panel;
p.Visible = false; //Error is showing on this line
Why this error ? Plz help..thnx
trying to hide a panel of Master Page in my content page using the following code
Panel p = this.Master.FindControl("panel1") as Panel;
p.Visible = false; //Error is showing on this line
Why this error ? Plz help..thnx
I suspect you've got the code like this:
class MyPage : Page
{
Panel p = this.Master.FindControl("panel1") as Panel;
p.Visible = false;
}
You can't just put code in the class like that - everything other than declarations (e.g. fields) needs to be in a method:
class MyPage : Page
{
public void Page_Load(object sender, EventArgs e)
{
Panel p = this.Master.FindControl("panel1") as Panel;
p.Visible = false;
}
}