Reference ASP.Net Page from a Master Page

Discussion in 'ASP .Net' started by =?Utf-8?B?Q2hhcmxpZQ==?=, Dec 11, 2006.

  1. 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
    =?Utf-8?B?Q2hhcmxpZQ==?=, Dec 11, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?Q2hhcmxpZQ==?=

    Mark Rae Guest

    "Charlie" <> wrote in message
    news:...

    >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...
    Mark Rae, Dec 11, 2006
    #2
    1. Advertising

  3. "Mark Rae" wrote:

    > "Charlie" <> wrote in message
    > news:...
    >
    > >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...
    >
    >
    >



    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 )
    =?Utf-8?B?Q2hhcmxpZQ==?=, Dec 11, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug McCann
    Replies:
    1
    Views:
    1,001
    William Brogden
    Aug 5, 2004
  2. BillE
    Replies:
    0
    Views:
    456
    BillE
    Nov 8, 2006
  3. Zeba
    Replies:
    1
    Views:
    485
    Mark Rae
    Feb 22, 2007
  4. Nathan Sokalski
    Replies:
    25
    Views:
    1,423
    Nathan Sokalski
    Mar 4, 2010
  5. SerpentKiss2010
    Replies:
    0
    Views:
    2,477
    SerpentKiss2010
    Apr 6, 2011
Loading...

Share This Page