Last post Oct 08, 2010 11:41 AM by rrinconua
Oct 08, 2010 11:01 AM|rrinconua|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?
Oct 08, 2010 11:25 AM|Curt_C|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.
Oct 08, 2010 11:31 AM|bruce (sqlwork.com)|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.
Oct 08, 2010 11:41 AM|rrinconua|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 :)