Reference ASP.Net Page from a Master Page

G

Guest

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.thePropertyIwant
or
this.Parent.thePropertyIwant
or
this.PageBase.thePropertyIwant
but I cant find the correct syntax

Any ideas?
Charlie
 
M

Mark Rae

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.thePropertyIwant
or
this.Parent.thePropertyIwant
or
this.PageBase.thePropertyIwant
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...
 
G

Guest

Mark Rae said:
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_authenticate 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).thePropertyIwant )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top