title: looping through Page Controls - using same logic for multiple control types
body: <p>I'm looping through the page controls like so</p>
  
  <pre><code>      foreach (Control ctrl in control.Controls)
        {
            if (ctrl is System.Web.UI.WebControls.TextBox || ctrl is System.Web.UI.WebControls.Label)
            {
            }
        }
  </code></pre>
  
  <p>I want to be able to declare a variable inside this if statements that is the same type as 'ctrl' in the foreach so that I can inspect the properties of the control and perform some manipulations that way.  I don't want to duplicate code, for example, if 'ctrl' is a textbox, or label, because I would be executing the same code for those 2 web control types.</p>
  
  <p>Any help leading me in the right direction is greatly appreciated!</p>
  
  <p>Thanks </p>