C# – Accessing controls inside a dynamically generated control

asp.netc

I'm creating instances of various controls at runtime in the Page_Load method of another control. The dynamically generated controls are then added to a Placeholder.

From inside the dynamically generated controls (in their own Page_Load method) I am trying to set the values of various Literals, but they are all null.

Can anyone shed some light on why I can't access these Literals?

Thanks
Ryan

Best Answer

Sorted. Need to use the LoadControl() method..

I was trying to created an instace of the control instead.

Related Topic