Groups | Blog | Home
all groups > asp.net webcontrols > april 2008 >

asp.net webcontrols : Supress Page_Load in ascx?


Peter
4/14/2008 5:58:18 AM
Hi

I have an aspx with some user controls (ascx) on it.

When the aspx is loaded, its Page_Load method is called, and
subsequently the Page_Load methods of the ascx's are called.

Is it possible in the Page_Load of the aspx to prevent the Page_Loads
of the ascx's from being called?


Thanks,
Peter

--
Peter
4/14/2008 12:04:15 PM
[quoted text, click to view]

Thanks for your answer - and I'll try to give more info.

I have one aspx, with several "placeholders" which are set to certain
ascx's at runtime (for example, a menu control, a list result control,
etc).

I am trying to implement a "login redirection handler" by using a
special control which is always loaded on my aspx, checks if there is a
logged in user, and if not then redirects to my login page.

The problem I experience with this approach (and I am not sure really
if this is a good approach or not) is that the "Page_Load" methods of
all the ascx's are called even though my "login redirection handler"
redirects to my login page. I want to stop the Page_Loads being called
if my login control decides a user is not logged in.

Patrice
4/14/2008 7:23:41 PM
Always ? This is likely not the best option (it's best to work with ASP.NET
rather than against it).

You could use IsPostback inside the control Load event to know if this is
the first load or not. Else elaborate a bit on the problem you are trying to
solve so that one could bring better suggestion (for example the code could
be better placed in another event).

--
Patrice


"Peter" <xdzgor@hotmail.com> a écrit dans le message de news:
OE0128inIHA.4372@TK2MSFTNGP05.phx.gbl...
[quoted text, click to view]

Patrice
4/15/2008 10:05:25 AM
How do you redirect ? See
http://msdn2.microsoft.com/en-us/library/a8wa7sdt.aspx and set the boolean
to true to force the current page to terminate.

(as a side note login handling is already part of the ASP.NET
infrastructure).


"Peter" <xdzgor@hotmail.com> a écrit dans le message de news:
ObABWJmnIHA.4292@TK2MSFTNGP04.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button