473,549 Members | 2,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Rem ove(UserControl 1)

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

Aug 22 '07 #1
2 7167
<ad*****@hotmai l.comwrote in message
news:11******** **************@ r29g2000hsg.goo glegroups.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.Rem ove(UserControl 1)

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
programmaticall y in Page_Load.

Riki
Aug 22 '07 #2
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
programmaticall y 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
programmaticall y and remove them from the webform design. I hope they
will add an "unload" feature
for vs2008.

Thanks,
Adiel

Aug 22 '07 #3

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

Similar topics

1
20163
by: Efkas | last post by:
My application have some level : 1. MyButton class with Label inheritance 2. MyComponent as User Control loading and positionning some of MyButtons 3. MyApp loading and positionning MyComponent I prefer don't insert a background in MyComponent, and using the MyApp one as general background with MyComponent positionned, but I am not able...
0
1032
by: Jo Inferis | last post by:
Disclaimer : I'm fairly new to .NET (about 4 weeks and counting now...) I have a page which contains multiple user controls, some of which it has access to the methods of (by making the controls inherit from a generic pre-compiled class). I want the containing page to read the value returned by one of the control methods and depending on the...
4
1923
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for some reason I keep getting the error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
2
1953
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for some reason I keep getting the error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
0
1913
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for some reason I keep getting the error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
3
2224
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for some reason I keep getting the error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
1
3445
by: Salvador | last post by:
Hi, I don't know why but I have a page that has one usercontrol (added dynamically on the servcer using LoadControl). If I execute the page and puts a breakpoint on Page_Load of the usercontrol its executes twice, any ideas? cheers Salva
0
1310
by: Joe | last post by:
I've a web form that inherits from a BasePage. There is a user control on the web form. Does anyone thinks it's a problem if I've my BasePage loading a user control and my web form loading a different user control. I'm more worry on the sequence as which user control gets loaded first. The user control I've on the web form depends on the...
5
2051
by: Norsoft | last post by:
I have a .Net 1.1 application which is downloaded into an aspx page. It is a dll which inherits from System.Windows.Forms.UserControl. It works fine on a PC with only the 1.1 Framework. However, the control will not load on a PC with the 2.0 Framework installed. I know that IE will use the newest framework so I assume it is a security issue. ...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7469
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

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.