473,666 Members | 2,039 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 2528
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

"ThunderMus ic" <No************ *************@N oSpAm.comwrote in message
news:ud******** ******@TK2MSFTN GP04.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.M asterPage. 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.Ma sterPage = CType(Me.Master , TechBear.Web.Ma sterPage)

If MyMP IsNot Nothing Then
MyMP.Property1 = "This value"
MyMP.ListOfMyOb jects.Add(New MyObject("value ", 1))
MyMp.CallThisMe thod()
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.P age, 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 MembershipProvi der 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.HasEx ecutiveRole Then...

or simply

If MyUser.HasExecu tiveRole 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
1981
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 instead of a true MasterPage layout, but it wasn't conducive to the SiteMap that I use throughout. The MasterPage paradigm is a good fit for the style of app, and everything else works perfectly except I'd prefer to stop the flickering. Since I...
9
4344
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 normal class? I have no problem to call the masterpage's methods from a contentpage, but what I would like to do is someting like this... public partial class MyMaster : System.Web.UI.MasterPage
3
2080
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, for example, that the Page_Load on the specific page executes before the Page_Load of its MasterPage. Is this right? But what I really want to understand is VARIABLE SCOPE, etc. between the two. For example: Is there a way for me to write code...
10
2235
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 as well.) I want to make a property named TitleResourceKey, for example, that contains the resource key used to translate the page title and, using reflection and the CustomLocalisationKey attribute that points to the property this key...
12
4919
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
2088
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
3096
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 inside form tag with runat = server". I understand that this is because my Masterpage has the formtag and not the eventslisting page, but cannot figure a workaround. I have tried overriding VerifyRenderingInServerForm and everything else I can...
2
7807
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 set to: enctype="multipart/form-data" On the rest of the pages, I do not need this. How can my specific ASPX page that uses the MasterPage change the
1
1741
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 can I access the public members of the User Control in the MasterPage from the derived page?
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7386
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.