473,385 Members | 1,324 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,385 software developers and data experts.

Master pages: Page_Load is backwards

Master pages run Page_Load() from the deepest level of nesting outwards. So
if I write a content page based on a nested master which is then based on
some other master, the Page_Loads are executed backwards:
Content page, SubMaster Page, Master Page.

Does this seem messed up to anyone else?? I can't see any logic in this.
But from what I understand, the whole master page scheme is cooked on top of
the usercontrol class. So the "master" really is a control in the content
page.

Any ideas for reversing the order of execution?

Thanks!
Apr 9 '06 #1
3 1613
No ideas on reversing them. Conceptually it make sense if you think of the
content page as being the real page that the master gets added to. If you
have a super master then it would get added to that master so from a call
chain it makes sense that you start with the content then call it's master
and then call it's master.

What are you trying to do? In general you'll have much better luck if you
always assume an event could always happen at a random time and in a random
order.

Apr 9 '06 #2
I agree with Larry, I think it makes sense that the content page's load
event fires first, and it then gets 'decorated' with the master page.
However, you have to be really careful with some other events, because
they fire the other way around: master page first.

This is the sequence of events that get fired when a content page is
merged with a master:

Master page controls Init event
Content controls Init event

Master page Init event
Content page Init event

Content page Load event
Master page Load event

Content page PreRender event
Master page PreRender event

Master page controls PreRender event
Content controls PreRender event

HTH,

Chris

Apr 9 '06 #3
"Larry Charlton" <La***********@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com...
No ideas on reversing them. Conceptually it make sense if you think of
the
content page as being the real page that the master gets added to. If you
have a super master then it would get added to that master so from a call
chain it makes sense that you start with the content then call it's master
and then call it's master.

What are you trying to do? In general you'll have much better luck if you
always assume an event could always happen at a random time and in a
random
order.


Hi Larry and Chris -

Thanks for the replies. I had the mindset that the master page and content
page have the same relationship as a derived and base class. I see what
you're saying about the 'added to' philosophy. Makes much more sense now,
thanks.

I'm trying to implement security. The page_load of a master page seemed a
convenient way to add security to a large group of web pages. The page_load
checks the users session and redirects to a login page if the user isn't
logged in. The login page is also passed a return url.

It works in a practical sense. The end result is what I want. But too many
page_load methods are being called and the extra processing is thrown away.

Here's an example:
User opens "Orders" page (requires login), Content.Page_Load() is executed
which queries the order table, Master.Page_Load() is executed which notices
the user isn't logged in and redirects to Login.aspx?returnurl=orders. The
Content.Page_Load() is needlessly executed.

I'm probably trying to reinvent the wheel with security. Is there something
precanned that will do the login stuff and the return url?

Thanks!

Apr 10 '06 #4

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

Similar topics

4
by: rmccinc | last post by:
Hello- I am missing something very easy here I think. I have 3 files test.master.vb (Master) content.aspx.vb (content) Control.ascx.vb (user Control)
7
by: Martijn Saly | last post by:
Hi there, I've created a master page with some controls on it, a Calendar control among others. Now depending on the date(s) selected, the content page needs to be updated. In the masterpage...
4
by: EagleRed | last post by:
I am writing an ASP.NET 2.0 application that uses more than one master page. Currently, there are two pages, Freedom1.master and Freedom2.master. I have no problems with Freedom1.master. However,...
6
by: Steve | last post by:
I'm trying to iterate over all the form controls in my MasterPages content page. Basically, I've got dropdowns, textboxes, etc that I want to format in Page_Load() I've added this code to my...
11
by: EagleRed | last post by:
I am writing an ASP.NET 2.0 application that uses master pages. I have some pages that must not be cached on the client. In ASP.NET 1.1 I achieved this using metatags: <meta...
8
by: JT | last post by:
Hi, I have done a fair amount of style editing inline in ASP. I'm now using VS 2005 with a standard web project (not Web Application Project). This is my first foray into CSS in a style sheet...
4
by: Mikaël PLOUHINEC | last post by:
Hello, I have created a master page with a css. How can I use css in the children pages? The css must be declared in the <head</headsection. Does I have to import all my css in my master? Is...
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
6
by: Homer J. Simpson | last post by:
Hi all, I have enough experience with HTML/classic ASP to get by, and I'm trying to learn ASP.NET. Traditionally, I've taken the habit of breaking out extra-long CSS files into multiple,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.