im trying to write a public function which can call in all my pages to clear all my textboxes after data has been inserted. i've used it like so:
public void clean(Control parent)
{
try
{
foreach (Control c in parent)
{
TextBox tb = c as TextBox; //if the control is a textbox
tb.Text = String.Empty; //display nothing
}
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
however, the foreach is coming up with an error saying
"cannot operate on variable types system.web.ui.control because it does not contain a public function for getenumerator.
can anyone suggest an alternative?