Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Replacing a user control with another one

Reply
Thread Tools

Replacing a user control with another one

 
 
John
Guest
Posts: n/a
 
      07-06-2003
Hi all,

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

Regards
John.


 
Reply With Quote
 
 
 
 
David Waz...
Guest
Posts: n/a
 
      07-06-2003
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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Hi all,
>
> How do I completely remove a dynamically-loaded user control and replace

it
> with another one?
>
> Regards
> John.
>
>



 
Reply With Quote
 
 
 
 
Victor Garcia Aprea [MVP]
Guest
Posts: n/a
 
      07-07-2003
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi all,
>
> How do I completely remove a dynamically-loaded user control and replace

it
> with another one?
>
> Regards
> John.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change web controls in one user control from another user control =?Utf-8?B?REo=?= ASP .Net 2 12-01-2005 08:26 AM
How to force a load of one control from another control on another form? et ASP .Net 1 06-29-2005 07:45 PM
How to force a load of one control from another control on another form? et ASP .Net Datagrid Control 0 06-29-2005 06:05 PM
How to access: a page from a User control, and another User controlfrom another one? qwerty ASP .Net 3 09-30-2004 05:32 PM
Manipulating a User Control from another User Control Tom Rowton ASP .Net 2 08-01-2003 08:18 PM



Advertisments