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)
void ClearInputs(ControlCollection ctrls)
    foreach (Control ctrl in ctrls)
        if (ctrl is TextBox)
            ((TextBox)ctrl).Text = string.Empty;


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


About the Author

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

QuestionHow to add an exempt button PinmemberDaniel Ian M. Del Rosario9-Mar-15 22:56 
GeneralMy vote of 4 PinmemberFlash2009-MX29-Nov-12 10:00 
GeneralMy vote of 5 PinmemberMember 935358923-Oct-12 3:52 
GeneralRe: ya its real. Thanks for your code.;) PinmemberCS140120-Sep-11 20:57 
GeneralRe: I think you are right....I guess, I took it a wrong way..:) Pinmembersachinsharmaa10220-Sep-11 3:24 
GeneralReason for my vote of 5 This might be helpful in my future r... PinmemberVarun Sareen18-Nov-11 1:47 
GeneralReason for my vote of 3 Reason for my vote of 3 Nice. Pinmembermaheshsanika15-Nov-11 22:21 
GeneralReason for my vote of 3 Nice. Pinmembermaheshsanika15-Nov-11 22:20 
GeneralAlthough nothing new, I like this one and have done similar ... PinmemberMarcus Kramer27-Oct-11 5:38 
Generalcorrect me if i'm wrong, but this will have no effect on nes... PinmemberEngleA4-Oct-11 10:13 
GeneralReason for my vote of 2 Old hat PinmemberJohn Kouw26-Sep-11 23:12 
GeneralReason for my vote of 5 ah ah ah :)! I laughed because this ... Pinmemberjonanirina26-Sep-11 22:14 
GeneralUse databinding, Luke! 8) PinmemberAlexander Voronin26-Sep-11 21:43 
GeneralReason for my vote of 3 nice Pinmembervipin bakaya26-Sep-11 19:28 
GeneralReason for my vote of 3 What is the purpose of Calling Clear... PinmemberPrabhu_R24-Sep-11 5:05 
GeneralRe: mr.Prabhu_R did u check my code before write this comment? D... PinmemberCS140125-Sep-11 19:28 
GeneralReason for my vote of 4 Seen many variations of this... almo... PinmemberBrianBissell20-Sep-11 3:47 
GeneralWhat about the situation where we need to clear some of the ... Pinmemberoorja20-Sep-11 1:20 
GeneralRe: if you want to clear the specific text box means u will writ... PinmemberCS140120-Sep-11 1:56 
GeneralRe: Check it out here: <b><a href=" Pinmember98z2820-Sep-11 10:25 
GeneralReason for my vote of 3 can be done more easily...i apprecia... Pinmembersachinsharmaa10219-Sep-11 22:56 
GeneralRe: This is the easiest way in my experience. In web application... PinmemberCS140120-Sep-11 0:42 

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
Web03 | 2.8.150331.1 | Last Updated 27 Sep 2011
Article Copyright 2011 by CS1401
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid