• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2572
  • Last Modified:

call master page control

I have my master page control with a panel1 in it. Its property visible is set to false.

In one of my pages for example- Links.aspx I want to set the panel1 property visible = true in my master page.

Is this possible?
0
caoimhincryan
Asked:
caoimhincryan
  • 3
  • 2
2 Solutions
 
cmhuntyCommented:
You can access the controls in the master page using me.Form.Parent.FindControl..........

So you'd have something like:

CType(me.Form.Parent.FindControl("panel1"),Panel).Visible = True
0
 
Munawar HussainPrincipal Software EngineerCommented:
in  Links.aspx

 MasterPage ms = (MasterPage)Master;
        Panel pp = (Panel)ms.FindControl("Panel1");
        pp.Visible = true;
0
 
Munawar HussainPrincipal Software EngineerCommented:
if want to short the code then this line
((Panel)((MasterPage)Master).FindControl("Panel1")).Visible = true;

VB.Net
Ctype(Ctype(Master,MasterPage).FindControl("Panel1"),Panel).Visible =True
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
caoimhincryanAuthor Commented:
Thanks for the quick response. Both work great but actually doesnt display for the context Im using it. Let me explain.

I have my panel in master page. Then on my links page i override the onError method so as to display my own error message.

Protected Overrides Sub OnError(ByVal e As System.EventArgs)
        MyBase.OnError(e)

        '    'do stuff here
        UpdatePanel1.Visible = False
       
        CType(Me.Form.Parent.FindControl("ErrorHandlerPanel"), Panel).Visible = True

       Response.Write(Server.GetLastError().Message)

        Server.ClearError()
       

    End Sub

To test this i have added Throw New ApplicationException("Blahh") on my page load event.

All thats displayed is "Blahh" . Would anyone know how to display my panel?
0
 
caoimhincryanAuthor Commented:
I never specified that my error message is in my panel on the master page hence why I want it to display.
0
 
caoimhincryanAuthor Commented:
I split the points. I feel I need to ask a new question for my current issue.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now