Setting master page properties from custom base page

W

William Youngman

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
 
B

bruce barker

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

-- bruce (sqlwork.com)
 
C

clintonG

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/


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
 
W

William Youngman

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
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
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top