Access Control

S

shapper

Hello,

I have am adding a user control to a master page.
In my user control VB code I need to access a control which is in the
master page.

I tried:
Dim myPanel As Panel = CType(Me.FindControl("Panel1"), Panel)
Dim myPanel As Panel = CType(Page.FindControl("Panel1"), Panel)
Dim myPanel As Panel = CType(MyBase.FindControl("Panel1"), Panel)

All of them gave me an error.

Could you tell me how to solve this?

Thanks,
Miguel
 
J

Jason Kohlhoff

You have to use the Master property, like this:

Dim myPanel As Panel = CType(Master.FindControl("Panel1"), Panel)

Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top