Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing control buried in another control
Message
From
21/09/2010 15:59:32
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
Application:
Web
Miscellaneous
Thread ID:
01482165
Message ID:
01482224
Views:
38
>>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
>>Tim
>
>
>FindControl isn't recursive - if it is inside of a container you need to call FindControl on the container instead. ex. this.holdSpecialSpecs.FindControl("holdDefendant");

Thanks Paul,

My placeHolder is in a RADPanelBar control. I just tried to access with:
this.CasePanelBar.FindControl("holdDefendant");
I had no joy with that either so I will try to do a recursive routine like Bruce showed to see if I can dig into the controls to find it.
Tim
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform