![]() |
|
|
|||||||
![]() |
ASP Net - Avoid execution of "Page_Load" of controls contained in MultiViewViews |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
> 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 |
|
|
|
#4 |
|
Posts: n/a
|
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 |
|
|
|
#5 |
|
Posts: n/a
|
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 |
|