Removing a user control dynamically

M

mazdotnet

Hi,

I have a user control that I add dynamically. Once certain action is
performed I want to remove it completely.

My questions are
1. How do you check to see if a user control already exists or not?
2. How do you remove it after it's been added?

I added by doing the following
Control ActivateOrderControl = LoadControl("activatelicense.ascx")
panelView.Controls.Add(ActivateOrderControl);

Thank you
Maz.
 
G

Guest

Hi,

I have a user control that I add dynamically. Once certain action is
performed I want to remove it completely.

My questions are
1. How do you check to see if a user control already exists or not?
2. How do you remove it after it's been added?

I added by doing the following
Control ActivateOrderControl = LoadControl("activatelicense.ascx")
panelView.Controls.Add(ActivateOrderControl);

Thank you
Maz.

Something like this

For Each c in Me.Controls
If c.Name = "..." Then
Me.Controls.Remove(c)
Exit For
End If
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top