Setting master page properties from custom base page

Discussion in 'ASP .Net' started by William Youngman, Mar 23, 2007.

  1. I am on a team that is developing a proposal generation web application and we are using a custom base page (ProGenBase.cs) located in the app_code directory and all of the app's web pages inherit from this custom page. Additionally I have a main menu tab control that is located in a master page and certain tabs are displayed dependant on the users authentication level. I am using boolean properties in the master page to control the visible state of the tabs. I have code in each web page that checks the users authentication level and depending on what the level is sets the master page visible property to true or false respectively.

    What I would like to do is move this code to the base page so the code is located in just one place and isn't being replicated in multiple pages - the old issue of if the code needs to be changed for whatever reason I'll only have to do it in one place vice multiple places (and hope that I got all of the pages). My problem is that I don't know how to access my master page properties from the base page class that is located in the app_code directory being that this is my first major .net 2.0 project.

    Any help/tricks/tips/suggestions will be greatly appreciated.

    TIA,
    Bill Youngman
    William Youngman, Mar 23, 2007
    #1
    1. Advertising

  2. William Youngman

    bruce barker Guest

    the master page should implement an interfase. the the base page can
    cast the master to this interface and access methods.

    -- bruce (sqlwork.com)

    William Youngman wrote:
    > I am on a team that is developing a proposal generation web application
    > and we are using a custom base page (/ProGenBase.cs/) located in the
    > app_code directory and all of the app's web pages inherit from this
    > custom page. Additionally I have a main menu tab control that is located
    > in a master page and certain tabs are displayed dependant on the users
    > authentication level. I am using boolean properties in the master page
    > to control the visible state of the tabs. I have code in each web page
    > that checks the users authentication level and depending on what the
    > level is sets the master page visible property to true or false
    > respectively.
    >
    > What I would like to do is move this code to the base page so the code
    > is located in just one place and isn't being replicated in multiple
    > pages - the old issue of if the code needs to be changed for whatever
    > reason I'll only have to do it in one place vice multiple places (and
    > hope that I got all of the pages). My problem is that I don't know how
    > to access my master page properties from the base page class that is
    > located in the /app_code/ directory being that this is my first
    > major .net 2.0 project.
    >
    > Any help/tricks/tips/suggestions will be greatly appreciated.
    >
    > TIA,
    > Bill Youngman
    bruce barker, Mar 23, 2007
    #2
    1. Advertising

  3. William Youngman

    clintonG Guest

    The quick answer is public properties. Read the first item returned by
    submitting the following search term to google...

    reference masterpage site:msdn2.microsoft.com

    Then go to http://odetocode.com/ where you'll find K. Scott Allen has
    documented what can be considered the definitive study of the use of
    MasterPages.

    <%= Clinton Gallagher
    NET csgallagher AT metromilwaukee.com
    URL http://clintongallagher.metromilwaukee.com/


    "William Youngman" <> wrote in message
    news:...
    I am on a team that is developing a proposal generation web application and
    we are using a custom base page (ProGenBase.cs) located in the app_code
    directory and all of the app's web pages inherit from this custom page.
    Additionally I have a main menu tab control that is located in a master page
    and certain tabs are displayed dependant on the users authentication level.
    I am using boolean properties in the master page to control the visible
    state of the tabs. I have code in each web page that checks the users
    authentication level and depending on what the level is sets the master page
    visible property to true or false respectively.

    What I would like to do is move this code to the base page so the code is
    located in just one place and isn't being replicated in multiple pages - the
    old issue of if the code needs to be changed for whatever reason I'll only
    have to do it in one place vice multiple places (and hope that I got all of
    the pages). My problem is that I don't know how to access my master page
    properties from the base page class that is located in the app_code
    directory being that this is my first major .net 2.0 project.

    Any help/tricks/tips/suggestions will be greatly appreciated.

    TIA,
    Bill Youngman
    clintonG, Mar 23, 2007
    #3
  4. I was able to accomplish what I needed by moving the objects into user controls and creating a couple of interfaces for them as well as creating a master page base class and having my master page inherit from that.

    I want to thank those who replied for their suggestions - they were very helpful. Also if anybody stumbles across this page while searching for solutions to the same issue I found this article on SitePoint that was invaluable-

    Master Pages hate logic. Throw Interfaces at them
    http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them
    "William Youngman" <> wrote in message news:...
    I am on a team that is developing a proposal generation web application and we are using a custom base page (ProGenBase.cs) located in the app_code directory and all of the app's web pages inherit from this custom page. Additionally I have a main menu tab control that is located in a master page and certain tabs are displayed dependant on the users authentication level. I am using boolean properties in the master page to control the visible state of the tabs. I have code in each web page that checks the users authentication level and depending on what the level is sets the master page visible property to true or false respectively.

    What I would like to do is move this code to the base page so the code is located in just one place and isn't being replicated in multiple pages - the old issue of if the code needs to be changed for whatever reason I'll only have to do it in one place vice multiple places (and hope that I got all of the pages). My problem is that I don't know how to access my master page properties from the base page class that is located in the app_code directory being that this is my first major .net 2.0 project.

    Any help/tricks/tips/suggestions will be greatly appreciated.

    TIA,
    Bill Youngman
    William Youngman, Apr 2, 2007
    #4
    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:
    991
    William Brogden
    Aug 5, 2004
  2. =?Utf-8?B?U3VyZXNo?=

    Accessing Master Page Custom Properties in Design Mode

    =?Utf-8?B?U3VyZXNo?=, Oct 21, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    362
    =?Utf-8?B?U3VyZXNo?=
    Oct 21, 2006
  3. Mick Walker
    Replies:
    3
    Views:
    428
    Brandon Gano
    Jul 24, 2007
  4. Harlan Messinger
    Replies:
    0
    Views:
    361
    Harlan Messinger
    Feb 18, 2008
  5. Nathan Sokalski
    Replies:
    25
    Views:
    1,403
    Nathan Sokalski
    Mar 4, 2010
Loading...

Share This Page