Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Avoid execution of "Page_Load" of controls contained in MultiViewViews

 
Thread Tools Search this Thread
Old 11-28-2007, 03:47 PM   #1
Default Avoid execution of "Page_Load" of controls contained in MultiViewViews


Hi,

the subject says it all. Since visible=false controls will still run
though Page_Load, I was hoping that the MultiView would somehow manage
to avoid a Page_Load of controls in its inactive Views. But of course
it does not.

I guess a safe way to avoid Page_Load is to only add the controls at
runtime into the activated view. Which of course neglects the beauty
of editing the layout if several views in one ascx.

Is there a more elegant way or at least a way to safely jump out of
Page_Load of the control (without checking the state of the parents,
please - since the control is not supposed to work in a View only).

TIA for any hint,

Regards
DC


DC
  Reply With Quote
Old 11-28-2007, 04:06 PM   #2
Dave Bush
 
Posts: n/a
Default Re: Avoid execution of "Page_Load" of controls contained in MultiView Views
I suppose you could put them in an ascx file and dynamically load them
using LoadControl() but, the only way this will work is if you never
switch views as part of a post back OR you don't use viewstate.

The reason it loads all of the controls is so that it can re-establish
the state of the objects.

-----Original Message-----
From: DC [private.php?do=newpm&u=]
Posted At: Wednesday, November 28, 2007 10:47 AM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Avoid execution of "Page_Load" of controls contained in
MultiView Views
Subject: Avoid execution of "Page_Load" of controls contained in
MultiView Views

Hi,

the subject says it all. Since visible=false controls will still run
though Page_Load, I was hoping that the MultiView would somehow manage
to avoid a Page_Load of controls in its inactive Views. But of course
it does not.

I guess a safe way to avoid Page_Load is to only add the controls at
runtime into the activated view. Which of course neglects the beauty
of editing the layout if several views in one ascx.

Is there a more elegant way or at least a way to safely jump out of
Page_Load of the control (without checking the state of the parents,
please - since the control is not supposed to work in a View only).

TIA for any hint,

Regards
DC



Dave Bush
  Reply With Quote
Old 11-28-2007, 08:10 PM   #3
Scott Roberts
 
Posts: n/a
Default Re: Avoid execution of "Page_Load" of controls contained in MultiView Views
> Is there a more elegant way or at least a way to safely jump out of
> Page_Load of the control (without checking the state of the parents,
> please - since the control is not supposed to work in a View only).


I believe that the "Visible" property automatically checks the visibility of
parent/container controls. So you could try:

public void Page_Load(blah,blah,blah)
{
if (this.Visible)
{
DoYourWork();
}
}



Scott Roberts
  Reply With Quote
Old 11-29-2007, 07:49 AM   #4
DC
 
Posts: n/a
Default Re: Avoid execution of "Page_Load" of controls contained in MultiViewViews
On 28 Nov., 21:10, "Scott Roberts" <srobe...@no.spam.here-webworks-
software.com> wrote:
> > Is there a more elegant way or at least a way to safely jump out of
> > Page_Load of the control (without checking the state of the parents,
> > please - since the control is not supposed to work in a View only).

>
> I believe that the "Visible" property automatically checks the visibility of
> parent/container controls. So you could try:
>
> public void Page_Load(blah,blah,blah)
> {
> if (this.Visible)
> {
> DoYourWork();
> }
>
>
>
> }- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -


Thank you, Scott. This works in most situations. It is however
unreliable, because visibility of the control may be changed after the
Page_Load (but before Render).


DC
  Reply With Quote
Old 11-29-2007, 07:53 AM   #5
DC
 
Posts: n/a
Default Re: Avoid execution of "Page_Load" of controls contained in MultiViewViews
On 28 Nov., 17:06, "Dave Bush" <davemb...@dmbcllc.com> wrote:
> I suppose you could put them in an ascx file and dynamically load them
> using LoadControl() but, the only way this will work is if you never
> switch views as part of a post back OR you don't use viewstate.
>
> The reason it loads all of the controls is so that it can re-establish
> the state of the objects.
>
>
>
> -----Original Message-----
> From: DC [mailto:d...@upsize.de]
>
> Posted At: Wednesday, November 28, 2007 10:47 AM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Avoid execution of "Page_Load" of controls contained in
> MultiView Views
> Subject: Avoid execution of "Page_Load" of controls contained in
> MultiView Views
>
> Hi,
>
> the subject says it all. Since visible=false controls will still run
> though Page_Load, I was hoping that the MultiView would somehow manage
> to avoid a Page_Load of controls in its inactive Views. But of course
> it does not.
>
> I guess a safe way to avoid Page_Load is to only add the controls at
> runtime into the activated view. Which of course neglects the beauty
> of editing the layout if several views in one ascx.
>
> Is there a more elegant way or at least a way to safely jump out of
> Page_Load of the control (without checking the state of the parents,
> please - since the control is not supposed to work in a View only).
>
> TIA for any hint,
>
> Regards
> DC- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -


Thanks, Dave. I was hoping that I only have to make sure that the
controls which are actually postback targets exist. I am unsure about
how "complete" the control tree must be for postbacks/viewstate to
work. I will try out.

Regards
DC


DC
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46