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

Tagged as

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

, 26 Sep 2011 CPOL
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)

Share

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

 
GeneralRe: ya its real. Thanks for your code.;) PinmemberCS140120-Sep-11 20:57 

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 | Terms of Use | Mobile
Web01 | 2.8.141220.1 | Last Updated 27 Sep 2011
Article Copyright 2011 by CS1401
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid