views:

267

answers:

1

How to get a reference to a control from its' string name in C#?

+7  A: 

Page.FindControl

If the Control is nested, use Control.FindControl from the parent Control. Otherwise, you'll have to write your own FindControlRecursive

davogones
Note: In collections of controls, the FindControl method will return a different instance of the control of that name. In ASP.NET, that control will have a unique name also. In other words, FindControlRecursive will return the 1st control of that name.
Greg Ogle