Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to remove user control at run-time?
Message
De
26/12/2004 14:25:59
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00972037
Message ID:
00972212
Vues:
15
That is right.

DataGrid oCtrl = (DataGrid) Page.FindControl("myGrid");
oCtrl.Visible = false;

In some cases you might need to know the name of another container before getting to the exact control you want. Maybe a panel or if you are using Infragistics controls an UltraWebTab.

// find the tab control on the web page
UltraWebTab oTab = (UltraWebTab) this.FindControl("myTab")

// find the grid in the UltraWebTab
DataGrid oGrid = (DataGrid) oTab.FindControl("myGrid")

enjoy.


Merry Christmas!


>Thank you. I presume by "control" I have to use the user control ID, right?
>
>>octrl = Page.FindControl("control")
>>
>>
>>>>>Page has user control (mycontrol.ascx)
>>>>>
>>>>>If I want to make it invisible or remove it in the Page_Load method, how do you do it?
>>>>>
>>>>
>>>>You probably don't need to remove it. Making it invisible has pretty much the same affect. All you need to do is set the Visible property to false and ASP.NET will basically skip output generation for this control (ie Render() doesn't fire).
>>>>
>>>>You can also use the Controls collection to remove the user control entirely.
>>>>
>>>
>>>My problem was that I could not figure out (still don't know how) to find this user control in the Controls collection. So I had to change the approach to get around this problem.
>>>
>>>Thank you for your input.
Gordon de Rouyan
DC&G Consulting
Edmonton, Alberta
Email: derouyag@shaw.ca
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform