473,513 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MasterPage inheriting a MasterPage... is it possible?

Hi,
Maybe there is another way of doing this, but here's my problem...

I have my web site where I have a master page to have a common layout and a
common behavior on all my pages (that's what it's intended for)... But now
here comes the time where some pages need some processing (like, is the user
logged? and those kind of things)... If it was only on 1 or 2 pages, I'd
says, i'll put it directly in the code and case closed, but there are 10-20
pages that need this behavior while 10-15 pages don't... So I'd inherit my
master page to include everything in the base masterpage into the new master
page that will do the additionnal processing... and use this inherited
master page in the pages that need the extra processing... Can it be done?

I've thought of another way... that would be to create some properties in
the master page code file and setting them in my "sub-pages" to know which
processing to use... I can set these properties fine in my "sub-pages" code,
but is it possible to set a Master Page's property right in the markup like
we do for user controls?

thanks a lot

ThunderMusic
Sep 26 '06 #1
2 2521
I'd say you need to implement user controls and use Membership, Roles and
Profiles to manage authentication and access control.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W

"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:ud**************@TK2MSFTNGP04.phx.gbl...
Hi,
Maybe there is another way of doing this, but here's my problem...

I have my web site where I have a master page to have a common layout and
a common behavior on all my pages (that's what it's intended for)... But
now here comes the time where some pages need some processing (like, is
the user logged? and those kind of things)... If it was only on 1 or 2
pages, I'd says, i'll put it directly in the code and case closed, but
there are 10-20 pages that need this behavior while 10-15 pages don't...
So I'd inherit my master page to include everything in the base masterpage
into the new master page that will do the additionnal processing... and
use this inherited master page in the pages that need the extra
processing... Can it be done?

I've thought of another way... that would be to create some properties in
the master page code file and setting them in my "sub-pages" to know which
processing to use... I can set these properties fine in my "sub-pages"
code, but is it possible to set a Master Page's property right in the
markup like we do for user controls?

thanks a lot

ThunderMusic

Sep 26 '06 #2
ThunderMusic wrote:
Hi,
Maybe there is another way of doing this, but here's my problem...

I have my web site where I have a master page to have a common layout and a
common behavior on all my pages (that's what it's intended for)... But now
here comes the time where some pages need some processing (like, is the user
logged? and those kind of things)... If it was only on 1 or 2 pages, I'd
says, i'll put it directly in the code and case closed, but there are 10-20
pages that need this behavior while 10-15 pages don't... So I'd inherit my
master page to include everything in the base masterpage into the new master
page that will do the additionnal processing... and use this inherited
master page in the pages that need the extra processing... Can it be done?
Yes, and I've done it successfully.

Master pages by default inherit from System.Web.UI.MasterPage. You can create a
custom class that inherits MasterPage, then use the Inherits attribute in the
<%@Master %tag to base the master page on your custom class. You can then
reference the public methods and properties of the new class through the client
page's Master property. In, say, the client page's PreRender event, you might
have this code:

Dim MyMP as TechBear.Web.MasterPage = CType(Me.Master, TechBear.Web.MasterPage)

If MyMP IsNot Nothing Then
MyMP.Property1 = "This value"
MyMP.ListOfMyObjects.Add(New MyObject("value", 1))
MyMp.CallThisMethod()
End If

I have a MasterPage class that does all kinds of nifty things, like set a title,
subtitle and list of "see also" links at the top of the page, display or not
display a logout and print button, place page styles and javascripts into the
header block (meaning my pages will validate properly), and a few other useful
tricks.

For items that have no bearing on the master page itself, you migh consider
creating a custom class that inherits System.Web.UI.Page, which is the base
class for a client page. I have one of those, too, with functions that retrieve
page parameters, handles cookies, as well as properties that give access to my
custom MembershipProvider object and, if the user is logged in, to an instance
of my custom MembershipUser object with data on the logged in user. Again, just
add the Inherits attribute to the <%@Page %tag; then you can use those custom
methods and properties through the page's Me object, so

If Me.MyUser.HasExecutiveRole Then...

or simply

If MyUser.HasExecutiveRole Then...

--
Gregory Gadow
Sep 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1969
by: Keith Patrick | last post by:
I'd like to get some semblance of SmartNavigation-like behavior in a MasterPage-based content navigation app (primarily the lack of "flicker") I had it working in a version that used a MultiView...
9
4337
by: Leffe Andersson | last post by:
Hi folks! I have a MasterPage with some public methods, and I would like to call them from a (app_code) class. Is it possible to set a directive or an assembly reference to a MasterPage from a...
3
2074
by: Alex Maghen | last post by:
Hi. I'm a little confused about the code that resides in the code-behind of a MasterPage and the code that resides in the code-behind of the actual pages that USE that MasterPage. I'm noticing,...
10
2219
by: Christophe Peillet | last post by:
I am trying to create a BasePage for use in a large asp.net application, that will centrally provide certain extra properties and logic to the application. (The web project makes use Master Pages...
12
4900
by: Mark Rae | last post by:
Hi, It's easy enough for a child page to manipulate its MasterPage's header simply by modifying the MasterPage thus: <header runat="server"> .... .... </header>
8
2079
by: Randy Smith | last post by:
Hi, I now need to add MasterPages to a number of existing forms, but when I add the code for MasterPage, the MasterPage does NOT appear when it runs. Any thoughts? TIA, Randy Smith
0
3088
by: =?Utf-8?B?Qm9i?= | last post by:
I have a GridView control in page called which is inheriting from a MasterPage. The normal code to export to GridView does not work and gives me an error - "Control of type GridView must be placed...
2
7802
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I have a MasterPage. The MasterPage actually contains the <formtag which is used throughout the site. On just certain pages that use that MasterPage, I need the "enctype" for the <formtag to be...
1
1733
by: zb | last post by:
Here is the scenario: I have a page derived from a MasterPage. The MasterPage has a user control that exposes two properties that as public and can be used by other objects. Question: How...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.