473,396 Members | 1,998 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,396 software developers and data experts.

How do I get rid of a usercontrol when I want to replace it withanother.

I have some code like this:
Dim control As Control
control = Page.LoadControl("../usercontrols/
AlertsForQA.ascx")
content.Controls.Add(control)
'content' is the ID of a 'span' control. This is my way of adding
usercontrols to a aspx page.
Maybe there is a better way.
Anyway, I find that I want to get rid of the user control at some
point, and replace it with another user control. I could just do an
'Add' of the new control, but that would not unload or otherwise get
rid of the first control. Is there any way to get rid of the first
control? Should I save the 'control' that I first added in a session
variable so that I can somehow get rid of it later? Will the first
control simply be removed if I do a postback and neglect to add it in
page load?
Thanks,
Marv.
Jun 27 '08 #1
1 917

<CO*********@lycos.comwrote in message
news:19**********************************@34g2000h sf.googlegroups.com...
>I have some code like this:
Dim control As Control
control = Page.LoadControl("../usercontrols/
AlertsForQA.ascx")
content.Controls.Add(control)
'content' is the ID of a 'span' control. This is my way of adding
usercontrols to a aspx page.
Maybe there is a better way.
Anyway, I find that I want to get rid of the user control at some
point, and replace it with another user control. I could just do an
'Add' of the new control, but that would not unload or otherwise get
rid of the first control. Is there any way to get rid of the first
control? Should I save the 'control' that I first added in a session
variable so that I can somehow get rid of it later? Will the first
control simply be removed if I do a postback and neglect to add it in
page load?
Thanks,
Marv.
When you do a postback the dynamic control is gone unless you add it in the
pre-init.

LS

Jun 27 '08 #2

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

Similar topics

0
by: karlodb | last post by:
Hi all, I've been struggling with some strange VB behaviour for the last two days. I have created a usercontrol and placed two buttons in it. One is anchored bottom and right. When place the...
9
by: Peter | last post by:
I have an Usercontrol on a WebForm, on this Usercontrol is a button, I want to save data that's residing on the WebForm when user clicks on the button that's on the UserControl. How do I call a...
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
2
by: John Olsen | last post by:
Hi. I`m building a small CMS, and want to add the possibility to include server side code inside static html-strings that is stored in a database. For e.g. in the string...
0
by: karlodb | last post by:
Hi all, I've been struggling with some strange VB behaviour for the last two days. I have created a usercontrol and placed two buttons in it. One is anchored bottom and right. When place the...
3
by: Charles Law | last post by:
In a user control, is it possible to replace the default mouse events with my own? In particular, I want the consumer of my control to get MouseMove events when the mouse is over my control, so...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
10
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
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,...
0
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...
0
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,...
0
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...

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.