MasterPage, UserControl and Webform

Discussion in 'ASP .Net Web Controls' started by kirkski, May 12, 2007.

  1. kirkski

    kirkski Guest

    The layout of my site is as follows:

    I've a MasterPage that contains a UserControl and attached to the
    MasterPage is webforms that contain the sites content.

    My porblem is how to access the UserControl on the MasterPage from
    within the Web Forms. I can access it no problem from the MasterPage
    as its available from intellisense. Oh, and i'm using C#

    Thanks in advance,

    Steve.
    kirkski, May 12, 2007
    #1
    1. Advertising

  2. kirkski

    Teemu Keiski Guest

    Hi,

    with Master.FindControl("UCControl1") where UCControl1 is the id of the UC.
    This way yo can get rerefence to the user control.

    Another option is op create a readonly property on the Master which exposes
    the UC . Then on content page, specify @MasterType directive whichs
    strongly-types Master property on content page (e.g on content page
    Master.PropertyName gives access to the UC you expose)

    You'll see concrete example of it at:
    http://forums.asp.net/thread/1168780.aspx


    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net




    "kirkski" <> wrote in message
    news:...
    > The layout of my site is as follows:
    >
    > I've a MasterPage that contains a UserControl and attached to the
    > MasterPage is webforms that contain the sites content.
    >
    > My porblem is how to access the UserControl on the MasterPage from
    > within the Web Forms. I can access it no problem from the MasterPage
    > as its available from intellisense. Oh, and i'm using C#
    >
    > Thanks in advance,
    >
    > Steve.
    >
    Teemu Keiski, May 12, 2007
    #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. =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=

    Usercontrol derived from Usercontrol - masterpage init is fired tw

    =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=, Feb 3, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    450
    =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=
    Feb 3, 2006
  2. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    MasterPage -> Page -> MasterPage Code Access

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Apr 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    7,871
    Steven Cheng[MSFT]
    Apr 14, 2006
  3. ThunderMusic
    Replies:
    2
    Views:
    434
    Gregory Gadow
    Sep 27, 2006
  4. Randy Smith
    Replies:
    9
    Views:
    411
    Mark Rae
    Apr 14, 2007
  5. mr t
    Replies:
    0
    Views:
    390
Loading...

Share This Page