473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2348
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: multiformity | last post by:
So I have been working on an opensource project for a while, and decided to really try to make it look better after focusing on the functionality most of this time. Up to now, I have simply used a...
4
by: RedHair | last post by:
I have a base page class A which inherits System.Web.UI.Page class then a aspx page B inherits class A and have a master page C. There is a property D (a string variable) in the master page C. ...
4
by: Bob | last post by:
In ASP.NET 1.1, I have a base page for all my pages in an application. The base page contains some common properties that every page needs, the code behind file of every page looks like this: ...
4
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: ...
4
by: Suresh | last post by:
Is there any way to access the custom properties of a master page from the aspx form? I know the custom properties of a master page can be accessed from the aspx.cs partial class by specifying...
1
by: simonZ | last post by:
Since i have to handling the event from master page in every content page, I created custom page class, which handles the master page event: public class myPage: System.Web.UI.Page { protected...
3
by: Mick Walker | last post by:
Hi All, I have a user control on my master page, which exposes 3 public properties (all boolean). Basically by the values of these properties, the user control builds a menu to for users to...
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
6
by: mike.gilmore | last post by:
Hi, I'm trying to move all my custom validation code into the master page. Unfortunately anytime I use the response, request, or trace objects in any master page module (other than page_load), ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.