473,396 Members | 1,886 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.

Replacing a user control with another one

Hi all,

How do I completely remove a dynamically-loaded user control and replace it
with another one?

Regards
John.
Nov 17 '05 #1
2 3140
To remove the old control:

parentControl.Controls.Remove(o_OldControl) ' remove ONE control
from parent
OR
ParentControl.Controls.Clear ' Remove ALL
controls from parent

Then, to add the new control:
parentControl.Controls.add(o_NewControl) ' add to parent as the
Next sibling
OR
parentControl.Controls.AddAt(iIndexPosition, o_NewControl) ' add to
parent at a specific location
You could also not put ANY control in your HTML template, and just add the
correct control within the code-behind at run-time.
"John" <a@b.com> wrote in message
news:#Z**************@tk2msftngp13.phx.gbl...
Hi all,

How do I completely remove a dynamically-loaded user control and replace it with another one?

Regards
John.

Nov 17 '05 #2
Hi John,

Just remove it from the control tree and add the new one, take a look at the
ControlCollection type

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

"John" <a@b.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi all,

How do I completely remove a dynamically-loaded user control and replace it with another one?

Regards
John.

Nov 17 '05 #3

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

Similar topics

3
by: MAL | last post by:
Hi I need to Replace the current entry in the History list with a new randomly genrated URL BEFORE following the link being clicked. I want to use the onclick property, replace the current...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
4
by: Josh Harris | last post by:
Here is my question: It is common to have many pieces of business logic encapsulated within asp.net user controls. This can be found in high visibility projects such as the iBuySpy portal from...
7
by: Ryan Taylor | last post by:
Hi. I have some code that dynamically generates a PDF and spits this content directly to the web browser. I use HTMLDoc to create the Pdf's from html. So the user can click on a button "Print...
1
by: Larry Neylon | last post by:
Hi, I'm working on a VBScript application on IIS6 and I'm looking for some advice about the best way of replacing or improving session variable usage. The application is in a secure extranet...
0
by: John Smith | last post by:
I still have not gotten this damn thing figured out and I'm asking for help one last time before I give up on it. I have a user control that contains a paged gridview control. The master page...
10
by: Tom Plunket | last post by:
I've got a bunch of code that runs under a bunch of unit tests. It'd be really handy if when testing I could supply replacement functionality to verify that the right things get called without...
1
by: deluded.soul | last post by:
Hi everyone, I have a form which has a subform. Now based on the user selection, I want to replace this subform with another at run time. One approach I tried was to have both the forms on the...
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
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: 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
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.