Home All Groups Group Topic Archive Search About

MasterPage, UserControl and Webform

Author
12 May 2007 8:20 AM
kirkski
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.

Author
12 May 2007 4:43 PM
Teemu Keiski
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




Show quoteHide quote
"kirkski" <stevekir***@hotmail.com> wrote in message
news:1178958025.771272.67850@o5g2000hsb.googlegroups.com...
> 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.
>

Bookmark and Share

Post Thread options