Click here to Skip to main content
Click here to Skip to main content

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

, 26 Sep 2011
Rate this:
Please Sign up or sign in to vote.
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);
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

CS1401
Software Developer (Junior) CS1401
India India


Any fool can write code that a computer can understand. Good programmers write code that humans can understand.


Comments and Discussions

 
GeneralMy vote of 5 PinmemberMember 935358923-Oct-12 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140718.1 | Last Updated 27 Sep 2011
Article Copyright 2011 by CS1401
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid