DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 22 Aug 2007 06:01:46 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    unknown
          2    Riki
          3    unknown


How to stop a user control from loading   
I added a user control to a webform in Asp.net 2.0.  I am also adding
several other user controls to this webform.  Now I am trying to find
a way to stop the user controls from loading up when I call the
webform.  I could possibly have 10 user controls in this page and I
would not want all of them to load up.  I would like to control which
user control loads up.  I have tried placing each user control in a
separate placeholder and then disabling the place holder for the
controls I don't need on the page_load of the webform.  But, I notice
the control still loads because I placed a break point in the
page_load of the user control and it is still being hit.  I even tried
using the following code:

Me.Controls.Remove(UserControl1)

In the page_load of the main webform but the controls still loads!
How can I stop the user control from loading up at all?  I hope this
is not a limitation of Asp.net 2.0 in that the user control HAS to
load once it is added to a webform...

Thanks Before Hand,
Adiel
Date:Wed, 22 Aug 2007 06:01:46 -0700   Author:  

Re: How to stop a user control from loading   
wrote in message 
news:1187787706.759858.188180@r29g2000hsg.googlegroups.com...

>I added a user control to a webform in Asp.net 2.0.  I am also adding
> several other user controls to this webform.  Now I am trying to find
> a way to stop the user controls from loading up when I call the
> webform.  I could possibly have 10 user controls in this page and I
> would not want all of them to load up.  I would like to control which
> user control loads up.  I have tried placing each user control in a
> separate placeholder and then disabling the place holder for the
> controls I don't need on the page_load of the webform.  But, I notice
> the control still loads because I placed a break point in the
> page_load of the user control and it is still being hit.  I even tried
> using the following code:
>
> Me.Controls.Remove(UserControl1)
>
> In the page_load of the main webform but the controls still loads!
> How can I stop the user control from loading up at all?  I hope this
> is not a limitation of Asp.net 2.0 in that the user control HAS to
> load once it is added to a webform...


It's because the controls are already loaded before the execution of 
Page_Load in the page.

Why exactly do you want to stop them from loading?
Is making them invisible not enough?

If you really want to stop them from loading, you should go for the reverse 
approach:
remove all of the controls from the webform in design, and add them 
programmatically in Page_Load.

Riki
Date:Wed, 22 Aug 2007 17:14:50 +0200   Author:  

Re: How to stop a user control from loading   
Hello Riki:



> Why exactly do you want to stop them from loading?


I want to stop them from loading because each user control is doing
additional loading of data, etc.  Even when it is not needed



> Is making them invisible not enough?


Making them invisible will still load the control.  You can see this
when you debug, it still loads the control.



> If you really want to stop them from loading, you should go for the reverse
> approach:
> remove all of the controls from the webform in design, and add them
> programmatically in Page_Load.


Thank you, I guess if there is no way to "unload" them, I will have to
use your approach: to load them
programmatically and remove them from the webform design.  I hope they
will add an "unload" feature
for vs2008.

Thanks,
Adiel
Date:Wed, 22 Aug 2007 12:39:04 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us