Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Setting master page properties from custom base page

Reply
Thread Tools

Setting master page properties from custom base page

 
 
William Youngman
Guest
Posts: n/a
 
      03-23-2007
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
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      03-23-2007
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

 
Reply With Quote
 
 
 
 
clintonG
Guest
Posts: n/a
 
      03-23-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
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


 
Reply With Quote
 
William Youngman
Guest
Posts: n/a
 
      04-02-2007
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the value of a Master page's control's property using a property of the Master page Nathan Sokalski ASP .Net 25 03-04-2010 03:42 AM
Showing custom properties for page subclasses in Properties pane Harlan Messinger ASP .Net 0 02-18-2008 04:45 PM
Setting Properties of User Control On Master Page Mick Walker ASP .Net 3 07-24-2007 05:18 PM
Accessing Master Page Custom Properties in Design Mode =?Utf-8?B?U3VyZXNo?= ASP .Net 4 10-21-2006 05:37 AM
seeking servlet "Master" keep getting "Master/servlet/Master" not found. Tomcat 5.0.25 Doug McCann Java 1 08-05-2004 09:16 PM



Advertisments