User240536124 posted
I know, old question. But I'm going to leave this here since it comes up in searches:
Gets a comma separated string of all the control IDs on a web form:
protected void FindControls()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
// form1.Controls
foreach (Control c in form1.Controls) //Page.Controls
{
String txtId = string.Empty;
if (c.GetType().Namespace == "System.Web.UI.WebControls")
{
txtId = c.ID;
sb.Append(txtId + ", ");
}
}
string cntrlList = sb.ToString();
}