Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to access the property of master page

Reply
Thread Tools

How to access the property of master page

 
 
RedHair
Guest
Posts: n/a
 
      03-28-2006
I have a base page class A which inherits System.Web.UI.Page class
then a aspx page B inherits class A and have a master page C.
There is a property D (a string variable) in the master page C.

How can I access the property D from the base page class A?

PS: I know how to use reflection to access control of master page C from the
base class A.


 
Reply With Quote
 
 
 
 
jan.hancic@gmail.com
Guest
Posts: n/a
 
      03-28-2006
You must obtain a refrence to your MasterPage.
Here is some Visual Basic code:

dim myMaster As YourMasterPageType = CType( Me.Master,
YourMasterPageType )
myMaster.YourProperty = "lalalalal"

 
Reply With Quote
 
 
 
 
clintonG
Guest
Posts: n/a
 
      03-28-2006
First of all, when working with MasterPages its more useful to refer to a
"Content Page" rather than "base page class A."
Secondly, we strongly type the Master by including the following in a
content page...

<%@ MasterType VirtualPath="~/Masters/Whatever.master" %>

We can then access controls in the MasterPage using one of two techniques:

* Early Bound: properties
* Late Bound: FindControl method

I really haven't tried to reuse a variable declared in the MasterPage from a
Content Page.

<%= Clinton Gallagher



"RedHair" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a base page class A which inherits System.Web.UI.Page class
> then a aspx page B inherits class A and have a master page C.
> There is a property D (a string variable) in the master page C.
>
> How can I access the property D from the base page class A?
>
> PS: I know how to use reflection to access control of master page C from
> the base class A.
>



 
Reply With Quote
 
RedHair
Guest
Posts: n/a
 
      03-29-2006
The reason I want to work with master page from the base page class A is
because
sometimes the master page will be a little bit different depends on the
asp.net page.
I need to pass the parameters from base page class to master page since all
aspx
pages inherit the base page class, I don't need to call the subroutine in
each page.


"clintonG" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> First of all, when working with MasterPages its more useful to refer to a
> "Content Page" rather than "base page class A."
> Secondly, we strongly type the Master by including the following in a
> content page...
>
> <%@ MasterType VirtualPath="~/Masters/Whatever.master" %>
>
> We can then access controls in the MasterPage using one of two techniques:
>
> * Early Bound: properties
> * Late Bound: FindControl method
>
> I really haven't tried to reuse a variable declared in the MasterPage from
> a Content Page.
>
> <%= Clinton Gallagher
>
>
>
> "RedHair" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I have a base page class A which inherits System.Web.UI.Page class
>> then a aspx page B inherits class A and have a master page C.
>> There is a property D (a string variable) in the master page C.
>>
>> How can I access the property D from the base page class A?
>>
>> PS: I know how to use reflection to access control of master page C from
>> the base class A.
>>

>
>



 
Reply With Quote
 
jan.hancic@gmail.com
Guest
Posts: n/a
 
      03-29-2006
Oops my bad, I have missunderstood your question.

I thought you want to access variables from the content page.

 
Reply With Quote
 
mfcmfc mfcmfc is offline
Junior Member
Join Date: Mar 2007
Posts: 1
 
      03-15-2007
Did you ever find a resolution to this problem? I am looking for a solution myself.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Access Master Page Controls from page.aspx doesn't inherit from master SerpentKiss2010 ASP .Net 0 04-06-2011 02:46 PM
Setting the value of a Master page's control's property using a property of the Master page Nathan Sokalski ASP .Net 25 03-04-2010 03:42 AM
How can I access a Master Page Public Property from a Base Page =?Utf-8?B?SmF5IFBvbmR5?= ASP .Net 6 11-14-2007 12:06 PM
Access property and control of master page from a customized parent page class RedHair ASP .Net Web Controls 5 03-23-2006 01:39 PM
Access property and control of master page from a customized parent page class RedHair ASP .Net 5 03-23-2006 01:39 PM



Advertisments