473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

need a program to clear all the textboxes content at a glance

Pls let me know is there any control to clear all textboxes at a time in C#

Thanks and regards
Sau
Jul 2 '07 #1
3 1218
nateraaaa
663 Expert 512MB
Pls let me know is there any control to clear all textboxes at a time in C#

Thanks and regards
Sau
Generally I write a method that will allow the user to click a Clear button that will clear all of the textboxes on a page.

Expand|Select|Wrap|Line Numbers
  1. protected void ClearTextboxes()
  2. {
  3. txtTextBox1.Text = "";
  4. txtTextBox2.Text = "";
  5. //repeat for the all of the textboxes on your page.
  6.  
  7. }
Nathan
Jul 2 '07 #2
r035198x
13,262 8TB
Generally I write a method that will allow the user to click a Clear button that will clear all of the textboxes on a page.

Expand|Select|Wrap|Line Numbers
  1. protected void ClearTextboxes()
  2. {
  3. txtTextBox1.Text = "";
  4. txtTextBox2.Text = "";
  5. //repeat for the all of the textboxes on your page.
  6.  
  7. }
Nathan
Unless they are looking for a way to do it dynamically without knowing the names of the textboxes.
Jul 2 '07 #3
r035198x
13,262 8TB
In which case they may try something like:

Expand|Select|Wrap|Line Numbers
  1. private void button1_Click ( object sender, EventArgs e ) {
  2.             Control[] controls = new Control[this.Controls.Count];
  3.             this.Controls.CopyTo(controls, 0);
  4.             foreach (Control box in controls ) {
  5.                 if (box.GetType ( ) == typeof ( TextBox )) {
  6.                     TextBox tbox = (TextBox)box;
  7.                     tbox.Text = "";
  8.                 }
  9.             }
  10.         }
Jul 3 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: T. Wintershoven | last post by:
Hello, I have a few textboxes placed on a SSTab control devided over 3 tabs Is there a way to clear all textboxes in one time in stead of one by one. Someone told me "Use for each item...
3
by: Oddball | last post by:
I have a problem with the positioning of two divisions. They are containined within a content division in which all the page content happens (ie not the menus, etc.). The behavior I would like...
0
by: Drew | last post by:
Hey, i am currently looking for a nice solution for the following problem ( i could not find a sufficient solution in the other postings ): I am having several textboxes on my page, some of them...
0
by: TN Bella | last post by:
Hi, Here is part of one sub where I want to clear all textboxes (there are three subs where I do this, one contains more textboxes, the other is below and the final one looks the same but omits...
1
by: Chris | last post by:
Hi, I have a page with quite a few textboxes and dropdownlist controls. How can I clear the textboxes and reset the dropdownlist after the data is sent to the database? Do I have to perform ...
18
by: jmd | last post by:
Hello, I posted the following in the C# forum but without one answer. But perhaps now in vb.net someone has some guidelines ! This is my question : I want to write a vb.net program that does...
16
by: Basil Fawlty | last post by:
Hi everyone, I have an assignment, to create a simple VB program that computes the volume of a cylinder. The Form is pretty simple, it has a label and text box for base radius, another for height...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
0
by: yabighelen | last post by:
HELP!!!!! I have to write a program that does this: Create a program that encrypts and decrypts a message... Inputs: A typed message Output: When the encrypt button is clicked the input...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.