65.9K
CodeProject is changing. Read more.
Home

How to clear a Multiple TextBox values in a single click in C# .NET

Sep 15, 2011

CPOL
viewsIcon

107320

Using this method, we can clear the text stored in a textbox easily.

protected void Button2_Click(object sender, EventArgs e)
{
    ClearInputs(Page.Controls);
}
void ClearInputs(ControlCollection ctrls)
{
    foreach (Control ctrl in ctrls)
    {
        if (ctrl is TextBox)
            ((TextBox)ctrl).Text = string.Empty;
        ClearInputs(ctrl.Controls);
    }
}