473,950 Members | 13,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference ASP.Net Page from a Master Page

I have some code in a basePage class
public class PageBase : Page {}

that I would like to access from a Master Page.

On the Master Page I would like to code something like
this.Page.thePr opertyIwant
or
this.Parent.the PropertyIwant
or
this.PageBase.t hePropertyIwant
but I cant find the correct syntax

Any ideas?
Charlie

Dec 10 '06 #1
2 1088
"Charlie" <Ch*****@discus sions.microsoft .comwrote in message
news:B5******** *************** ***********@mic rosoft.com...
>I have some code in a basePage class
public class PageBase : Page {}

that I would like to access from a Master Page.

On the Master Page I would like to code something like
this.Page.thePr opertyIwant
or
this.Parent.the PropertyIwant
or
this.PageBase.t hePropertyIwant
but I cant find the correct syntax

Any ideas?
The code behind an aspx page is just a class like any other class...

However, the code behind an aspx page is really intended solely for that
page... If you have code in an aspx page's partial class which you need
outside that page, you should really consider moving it into a separate
class...
Dec 11 '06 #2


"Mark Rae" wrote:
"Charlie" <Ch*****@discus sions.microsoft .comwrote in message
news:B5******** *************** ***********@mic rosoft.com...
I have some code in a basePage class
public class PageBase : Page {}

that I would like to access from a Master Page.

On the Master Page I would like to code something like
this.Page.thePr opertyIwant
or
this.Parent.the PropertyIwant
or
this.PageBase.t hePropertyIwant
but I cant find the correct syntax

Any ideas?

The code behind an aspx page is just a class like any other class...

However, the code behind an aspx page is really intended solely for that
page... If you have code in an aspx page's partial class which you need
outside that page, you should really consider moving it into a separate
class...

Actually I agree!

The code in question is to do with the user. Ideally I would create a user
object (probably at Application_aut henticate request) and store this in the
session
and then I would be able to refer to it when nd where ever

the answer to my post though is
on the master page.cs have
if ( ((PageBase)this .Page).thePrope rtyIwant )

Dec 11 '06 #3

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

Similar topics

0
1312
by: Abraham Andres Luna | last post by:
i have a master page: <%@ Master Language="C#" %> <html> <head> <title>CRM - RDK Truck Sales & Service</title> </head> <body> <form runat="server"> <asp:contentplaceholder id="cphMainContent" runat="server">Content
8
2377
by: PJ | last post by:
How can I get a reference to the master page class? It is defined as a partial class, but I cannot seem to type a variable to the name of the partial class? The compiler continually shows "The type 'MyMaster' is not defined." I would like to reference the master page from a control, by casting the Master property of the Page property to the type, but obviously I cannot do this if I can't get a reference to the actual type. Thanks,
0
1079
by: John Holmes | last post by:
I have a website that consists of numerous ASP.NET applications (each referred to as a website in VS 2005) which I'd like to have share a master page. My directory structure on the website is like this: /Apps/App1, /Apps/App2, /Apps/Common, /Apps/App3, ... So the path to any one of these apps can be referred to as /Apps/App1/default.aspx and depending on if it's on our public site, dev site, test site, or intranet site the correct URL...
13
6252
by: Michael | last post by:
I have setup a public variable in the Master Page "code-behind-file". Now I would like to set that value from the UserControl, but I can't seem to find a way to do this. Does anyone have any ideas? I'm basically trying to set it up so that I can keep the User infor (userid, ect) in the Masterpage so that other pages can access it. Thanks for any ideas. Michael
3
2352
by: Managed Code | last post by:
I have a BasePage class that derives from System.Web.UI.Page. All of my content pages derive from this. The derived page classes use the following MasterType declaration that follows to reference the master. <%@ MasterType TypeName="MyMasterPage" %> How do I reference the master page class from the BasePage? Thanks...
0
10171
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10703
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9904
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8268
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7443
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6233
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6352
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4967
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 we have to send another system
2
4551
muto222
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.