I'm trying to do a validation in the master page (if user not logged in, redirect to main menu page kind of thing). I want to put it in the master page' page_preload (not in the page_load as I guess the content pages' load fires first), so I thought of putting
it in the page_preload of the master page, but it won't let me. It says 'preload event cannot be found' or something. What am I doing wrong?
master "page"s are a usercontrol hosted by the actual Page, so they only go thru a controls lifecycle, not the page lifecycle.
as suggested the best approach is a base page class, so you can have common code shared among pages. Another is to use one of the Request events supported by the Application class or just configure the built-in authentication to do it.
bruce (sqlwork.com)
Marked as answer by rrinconua on Oct 08, 2010 03:38 PM
I see. I'm coming from ASP where I would put the code in a file and just do #include on the other pages. I assumed master pages would do the equivalent thing, but guess I was wrong. I'll check on that base page to inherit thing, do you recommend any site
that shows how to do that in simple stupid terms? (in VB if possible). I'll google for it (reading first result now), but maybe there's THE place to read :)
rrinconua
Member
4 Points
19 Posts
No 'page_preload' on master page?
Oct 08, 2010 03:01 PM|LINK
I'm trying to do a validation in the master page (if user not logged in, redirect to main menu page kind of thing). I want to put it in the master page' page_preload (not in the page_load as I guess the content pages' load fires first), so I thought of putting it in the page_preload of the master page, but it won't let me. It says 'preload event cannot be found' or something. What am I doing wrong?
page_preload
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: No 'page_preload' on master page?
Oct 08, 2010 03:25 PM|LINK
Stick it in a Base page that you have all your site pages inherit from, then it's still in one location for maintenance.
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
bruce (sqlwo...
All-Star
37604 Points
5573 Posts
Re: No 'page_preload' on master page?
Oct 08, 2010 03:31 PM|LINK
master "page"s are a usercontrol hosted by the actual Page, so they only go thru a controls lifecycle, not the page lifecycle.
as suggested the best approach is a base page class, so you can have common code shared among pages. Another is to use one of the Request events supported by the Application class or just configure the built-in authentication to do it.
rrinconua
Member
4 Points
19 Posts
Re: No 'page_preload' on master page?
Oct 08, 2010 03:41 PM|LINK
I see. I'm coming from ASP where I would put the code in a file and just do #include on the other pages. I assumed master pages would do the equivalent thing, but guess I was wrong. I'll check on that base page to inherit thing, do you recommend any site that shows how to do that in simple stupid terms? (in VB if possible). I'll google for it (reading first result now), but maybe there's THE place to read :)