How to check if control is enabled with control name stored in database
I have a control name stored in a database table. I would like to pass the control name I retrieve from the database and check whether the control is enabled. How do I pass the string which has the control name to the c# code and check if enabled.
If I knew the control name ahead of time I would simply do:
Note that Findcontrol only searches it's direct children. If you need to, you can recurse by doing the following:
Private Control FindControlRecurrsive(Cont
if (parent.Name.tolower() == name.tolower()) // I always ignore case when comparing names.
for each ctrl in Parent.Controls
if (ctrl.Name == name)
else if (ctrl.Controls.Count > 0)
Control ctrl = MyForm.FindControl(myContr
if (ctrl != null && ctrl.IsEnabled)