title: A Better way? Finding ASP.NET controls, finding their id
body: <p>I have a method that finds all the controls, iterates through them, determines if they are a textbox,drop down list, etc.. retrieves their ID name, and depending on the ID name it will set a boolean statement (thus I would know if that section of the form is complete, and will email to a certain group of people) unfortunetly this is done with too many if statements and was wondering if I could get some help making this more manageable</p>
  
  <pre><code>protected void getEmailGroup()
  {
      Control[] allControls = FlattenHierachy(Page);
      foreach (Control control in allControls)
      {
          if (control.ID != null)
          {
              if (control is TextBox)
              {
                  TextBox txt = control as TextBox;
                  if (txt.Text != "")
                  {
                      if (control.ID.StartsWith("GenInfo_"))
                      {
                          GenInfo = true;
                      }
                      if (control.ID.StartsWith("EmpInfo_"))
                      {
                          EmpInfo = true;
                      }
                  }
              }
              if (control is DropDownList)
              {
                  DropDownList lb = control as DropDownList;
                  if (lb.SelectedIndex != -1)
                  {
                      if (control.ID.StartsWith("GenInfo_"))
                      {
                          GenInfo = true;
                      }
                      if (control.ID.StartsWith("EmpInfo_"))
                      {
                          EmpInfo = true;
                      }
                  }
              }
          }
      }
  }      
  </code></pre>