drupal stats

Clear all TextBox value from a Panel in ASP.NET

July 1st, 2011 PanelTextBox 2 Comments


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        ClearTextBoxes(Panel1);

    }

 

    protected void ClearTextBoxes(Control control)

    {

        foreach (Control c in control.Controls)

        {

            if (c is TextBox)

                ((TextBox)c).Text = "";

            if (c is CheckBox)

                ((CheckBox)c).Checked = false;

        }

    }

}

Tags: how to clear the textbox in asp net, clear all textbox in asp net, how to clear all textboxes in asp net c#, how to clear all textboxes in asp net, how to clear all textboxes in asp net using javascript, how to clear textbox value in javascript, how to clear the textbox values in asp net, how to clear text box value in javascript, clear textbox asp net, clear textbox value in javascript

Related posts:

  1. Clear TextBox on Focus in ASP.NET
  2. Export GridView to Excel in ASP.NET
  3. Clear TextBox Using Javascript
  4. Load a txt file into TextBox
  5. Multiline in Label ASP.NET

2 Comments

  1. adam spencer says:

    works great!
    I put into a public utility class and made the class and method static.
    Now can call from anywhere!

    public static class Utilities
    {
    public static void ClearTextBoxes(Control control)//usage Utilities.ClearTextBoxes(pnlShipping);
    {
    foreach (Control c in control.Controls)
    {
    if (c is TextBox)
    ((TextBox)c).Text = string.Empty;
    if (c is CheckBox)
    ((CheckBox)c).Checked = false;
    }
    }
    }

    //usage Utilities.ClearTextBoxes(pnlShipping);