I'm having a class which adds some controls into my web form. Now i need to access dynamically added controls by my class. Can any one tell me how can i access dynamically added controls from server side code.
I've find a solution for problem.Looping through all controls.
public static IEnumerable<Control> GetControls(ControlCollection controlCollection)
{
foreach (Control control in controlCollection)
{
yield return control;
if (control.Controls == null || control.Controls.Count == 0)
continue;
foreach (var sub in GetControls(control.Controls))
{
yield return sub;
}
}
}
After creating IEnumerable list check for the Control's ID.
foreach (Control c in ctr__)
{
if (c.ClientID == "dropUGrp")
{
//Code goes here
break;
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments