If you want to clear/Reset all Textboxes on a form, below solution will help you clear all Textboxes at a time.
You can write a simple funtion using below code,
public static void ClearAllTextBoxes(Control oControl)
{
foreach (Control ct in oControl.Controls)
{
if (ct is TextBox)
{
TextBox tb = (TextBox)ct.FindControl(ct.ID);
tb.Text = string.Empty;
}
if (ct.HasControls())
{
ClearAllTextBoxes(ct);
}
}
}
Call above Funtion using below code,
ClearAllTextBoxes(this);
No comments:
Post a Comment