473,378 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Avoid execution of "Page_Load" of controls contained in MultiViewViews

DC
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
Nov 28 '07 #1
4 2097
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:dc@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

Nov 28 '07 #2
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();
}
}

Nov 28 '07 #3
DC
On 28 Nov., 21:10, "Scott Roberts" <srobe...@no.spam.here-webworks-
software.comwrote:
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).
Nov 29 '07 #4
DC
On 28 Nov., 17:06, "Dave Bush" <davemb...@dmbcllc.comwrote:
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
Nov 29 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Patrick Marti | last post by:
I wish to create some LinkButtons in DotNet. Because I will do it in dependence of the entries in a database, I can not add them with the mouse to the form as usually. I can create them in the...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
2
by: Jon Hyland | last post by:
This might be a dumb question, but what is the best way for one instance of a user control to access properties of an instance of another user control? For example, let's say I have an instance...
2
by: Ranginald | last post by:
Hi, I have two pages. Default.aspx ....Codefile="default.aspx.cs" Inherits="Web" %> and Sculpture.aspx
5
by: tshad | last post by:
I have a PageInit.ascx that I want to put in all my pages and have it execute only once during the "not IsPostback" section. I also need it to execute first before anything else. I have it set...
2
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
4
by: Spectre1337 | last post by:
Hello, to my understanding the ASP.NET process works as follows: 1) Page_Init(): At this moment the user should allocate his controls, set their IDs and connect them to the page...
16
by: mj.redfox.mj | last post by:
Can anyone help? I have a textbox which I'm programatically adding by using the following code: txtTest = New TextBox txtTest.ID = "txtLeft" + cntCount.ToString...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.