469,578 Members | 1,933 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Setting master page properties from custom base page

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
Mar 23 '07 #1
3 2230
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
Mar 23 '07 #2
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" <wy*******@brinkercapital.comwrote in message
news:Oq**************@TK2MSFTNGP05.phx.gbl...
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
Mar 23 '07 #3
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/...rfaces-at-them
"William Youngman" <wy*******@brinkercapital.comwrote in message news:Oq**************@TK2MSFTNGP05.phx.gbl...
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
Apr 2 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by RedHair | last post: by
4 posts views Thread by Bob | last post: by
4 posts views Thread by Boris Yeltsin | last post: by
1 post views Thread by simonZ | last post: by
3 posts views Thread by Mick Walker | last post: by
6 posts views Thread by =?Utf-8?B?SmF5IFBvbmR5?= | last post: by
6 posts views Thread by mike.gilmore | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.