Access Control

Discussion in 'ASP .Net' started by shapper, Dec 14, 2006.

  1. shapper

    shapper Guest

    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
    shapper, Dec 14, 2006
    #1
    1. Advertising

  2. You have to use the Master property, like this:

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

    Jason

    "shapper" <> wrote in message
    news:...
    > 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
    >
    Jason Kohlhoff, Dec 14, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren Smith
    Replies:
    5
    Views:
    5,506
    dsmith
    May 10, 2004
  2. Karl
    Replies:
    0
    Views:
    570
  3. nail
    Replies:
    0
    Views:
    1,528
  4. xz
    Replies:
    9
    Views:
    518
    James Kanze
    Jan 8, 2008
  5. Hans Östlund
    Replies:
    1
    Views:
    161
    Alessandro Zifiglio
    Feb 5, 2004
Loading...

Share This Page