i want to clear all textboxes. wrote the public function as:
public void clean(Control parent)
{
try
{
foreach (Control c in parent.Controls)
{
TextBox tb = c as TextBox; //if the control is a textbox
if (tb != null)//Will be null if c is not a TextBox
{
tb.Text = String.Empty;//display nothing
}
}
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
in the class of the page i want it to be called i declared:
PublicFunctions pubvar = new PublicFunctions();
and i call it as
pubvar.clean(Page);
but its not working... not even throwing an error... and my textboxes arent clearing... help?