Supress Page_Load in ascx?

P

Peter

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

--
 
P

Peter

Patrice said:
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).

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.

/Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top