473,473 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to access the property of master page

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.
Mar 28 '06 #1
4 6001
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"

Mar 28 '06 #2
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" <re*****@ms40.url.com.tw> wrote in message
news:uc**************@TK2MSFTNGP12.phx.gbl...
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.

Mar 28 '06 #3
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" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <re*****@ms40.url.com.tw> wrote in message
news:uc**************@TK2MSFTNGP12.phx.gbl...
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.


Mar 29 '06 #4
Oops my bad, I have missunderstood your question.

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

Mar 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve Franks | last post by:
I am trying to access strongly typed properties in a page's master page from the content page. I followed an article that describes how to do this, and it seems quite straight forward. However...
5
by: RedHair | last post by:
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...
3
by: Alex Maghen | last post by:
Hi. I'm a little confused about the code that resides in the code-behind of a MasterPage and the code that resides in the code-behind of the actual pages that USE that MasterPage. I'm noticing,...
4
by: Bob | last post by:
In ASP.NET 1.1, I have a base page for all my pages in an application. The base page contains some common properties that every page needs, the code behind file of every page looks like this: ...
3
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property...
4
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: ...
0
by: Matt | last post by:
I am trying to access a property that I have created inside a Master Page. However all instruction that I have found shows them accessing the property from a .aspx page not a .aspx.vb page. My...
13
by: Kirk | last post by:
I have been reading Scott Allen's article on Master Pages (http:// odetocode.com/Articles/450.aspx) but I am having problems understanding a concept. Specifically, I have created a property...
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.