Home All Groups Group Topic Archive Search About

Access property and control of master page from a customized parent page class

Author
22 Mar 2006 9:34 PM
RedHair
I have a ASP.NET 2.0 web page which inherits a customized base page class
and have a master page,
their relation is as below

Customized base page class --> web page --> master page

How to access the property and control of master page from the customized
base page class?

Btw, I can access the server control of master page from base page class via
Cast + FinndControl,
however this method doesn't work on access a user control. how to solve?

Thanks in advance!

Author
22 Mar 2006 9:59 PM
clickon
You could try exposing the control as a property in the master page.



Show quoteHide quote
"RedHair" wrote:

> I have a ASP.NET 2.0 web page which inherits a customized base page class
> and have a master page,
> their relation is as below
>
> Customized base page class --> web page --> master page
>
> How to access the property and control of master page from the customized
> base page class?
>
> Btw, I can access the server control of master page from base page class via
> Cast + FinndControl,
> however this method doesn't work on access a user control. how to solve?
>
> Thanks in advance!
>
>
>
Author
22 Mar 2006 10:08 PM
RedHair
Thanks for reply, however the base class can't access the property of master
page


Show quoteHide quote
"clickon" <clic***@discussions.microsoft.com> wrote in message
news:2A01DD12-C320-446A-A9CF-26E9D9139A0F@microsoft.com...
> You could try exposing the control as a property in the master page.
>
>
>
> "RedHair" wrote:
>
>> I have a ASP.NET 2.0 web page which inherits a customized base page class
>> and have a master page,
>> their relation is as below
>>
>> Customized base page class --> web page --> master page
>>
>> How to access the property and control of master page from the customized
>> base page class?
>>
>> Btw, I can access the server control of master page from base page class
>> via
>> Cast + FinndControl,
>> however this method doesn't work on access a user control. how to solve?
>>
>> Thanks in advance!
>>
>>
>>
Author
22 Mar 2006 10:09 PM
CaffieneRush@gmail.com
I don't know if I understood your question correctly but here goes.

'Access base class' master page.
Dim myBMP As MasterPage = Me.MyBase.Master

'Find a user control called "myControl" in base class' master
Dim myControl As UserControl = myBMP.FindControl("myControl")
'Or perhaps
Dim myControl As UserControl = CType(MyBMP.FindControl("myControl"),
UserControl)
Author
23 Mar 2006 5:49 AM
RedHair
I am trying to access the page's master page from this page's parent class.


<CaffieneR***@gmail.com>
???????:1143065341.922150.98***@i40g2000cwc.googlegroups.com...
Show quoteHide quote
>I don't know if I understood your question correctly but here goes.
>
> 'Access base class' master page.
> Dim myBMP As MasterPage = Me.MyBase.Master
>
> 'Find a user control called "myControl" in base class' master
> Dim myControl As UserControl = myBMP.FindControl("myControl")
> 'Or perhaps
> Dim myControl As UserControl = CType(MyBMP.FindControl("myControl"),
> UserControl)
>