I'm looping through the page controls like so
foreach (Control ctrl in control.Controls)
{
if (ctrl is System.Web.UI.WebControls.TextBox || ctrl is System.Web.UI.WebControls.Label)
{
}
}
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.
Any help leading me in the right direction is greatly appreciated!
Thanks