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

By , 26 Sep 2011
 
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
Member


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


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralReason for my vote of 5 This might be helpful in my future r...memberVarun Sareen18 Nov '11 - 0:47 
Reason for my vote of 5
This might be helpful in my future requirement

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 27 Sep 2011
Article Copyright 2011 by CS1401
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid