Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing control buried in another control
Message
De
24/09/2010 10:26:40
 
 
À
24/09/2010 07:51:05
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
ASP.NET
Application:
Web
Divers
Thread ID:
01482165
Message ID:
01482566
Vues:
44
>>>>>Hi all,
>>>>>
>>>>>I have used place holder controls fairly often for adding user controls dynamically at runtime. Typically, I can access a placeholder directly and just add a control like this.
>>>>>
>>>>>ctrlSpecialSpecs specialSpecControl = (ctrlSpecialSpecs)Page.LoadControl("~/ORCSelection/UserControls/ctrlSpecialSpecs.ascx");
>>>>>           
>>>>>// Add the Control to the Placeholder
>>>>>this.holdSpecialSpecs.Controls.Add(specialSpecControl);
>>>>>
>>>>>
>>>>>Currently I have a place holder that is inside another complex control and accessing it this way just doesn't work as the control is not visible. I tried to do a find control like this, but get a null reference exception on the control.
>>>>>
>>>>>mmPlaceHolder defendantHolder = (mmPlaceHolder)this.Page.FindControl("holdDefendant");
>>>>>defendantHolder.Controls.Add(defendantDisplay);
>>>>>
>>>>>
>>>>>It is defined on the page like this; very straight forward.
>>>>>
>>>>> <mm:mmPlaceHolder ID="holdDefendant" runat="server" >
>>>>> </mm:mmPlaceHolder>
>>>>>
>>>>>
>>>>>Anybody have any ideas on how to get access to this control?
>>>>>Thanks
>
>Hi Robert,
>I converted your code to C sharp and it works great plus solved the problem. I still have this in my page code but plan to move it somewhere more useful, possibly my base page class.
>Thanks a bunch and also to Paul
>Tim

You're welcome!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform