Powered by Blogger.

Wednesday, May 7, 2014

Clear textboxes inside a form in C#.Net

In this post we will discuss how to clear textboxes inside a form in C#.Net.

Also you can check out:

- Remove column from datatable in Asp.Net

- How to handle exception in sql server stored procedure?

- Array and ArrayList in C#.Net

If you have very less controls in a form then you can clear like below:

txtName.Text = "";
txtAge.Text= "";``````````

But if you have more controls in the form then you can clear the values like below:

Below is the full method:

public void CleartextBoxes(Control parent)

        foreach (Control x in parent.Controls)
            if ((x.GetType() == typeof(TextBox)))
                ((TextBox)(x)).Text = "";

            if (x.HasControls())

You can call the method from button click like below:

protected void Button1_Click(object sender, EventArgs e)

This code will clear all the textboxes presented in the form.


Priya R November 12, 2016 at 1:43 AM

I have read this content it is very nice with unique information and keep updating us.
SEO Training in Chennai | best seo training institute in Chennai

Priya R November 14, 2016 at 2:09 AM

Very interesting content which helps me to get the in depth knowledge about the technology. To know more details about the course visit this website.
Digital marketing course in Chennai | Digital marketing training in Chennai

Paul Miller November 21, 2016 at 6:00 AM

I ever had seen this information over the blog sites; actually I am looking forward for this information. Here I had an opportunity to read, it is crystal clear keep sharing…I have an expectation to see your upcoming post.
Java Courses in Chennai|J2EE Training in Chennai|JAVA Training Chennai

Paul Miller November 26, 2016 at 1:54 AM

I went through your blog and it’s totally awesome. Keep on updating your site with such informative post. If possible please include rss feed for your blog. Web designing Course in Chennai

https://www.bravetechnologies.in December 8, 2016 at 2:25 AM

I have read your blog its very informative. Keep Updating.erp software solutions chennai|erp in chennai

Amirtha rao February 20, 2017 at 6:34 AM

Hi Admin, I went through your article and it’s totally awesome. You can consider including RSS feed for easy content sharing, So that you can drive huge traffic to your blog. Hadoop Training in Chennai | Big Data Training in Chennai

SKARtec SEO March 7, 2017 at 12:44 AM

Thanks for sharing this with us it is a worth read. xcellent post!!! Our Digital Marketing Course is tailored for beginners who want to learn how to stand out digitally, whether it is for their own business or a personal brand.

Digital Marketing Training in Chennai | Digital Marketing Course in Chennai | Digital Marketing Course | SEO Training in Chennai | Google Analytics Course | Social Media Marketing Course

Siva Seo March 7, 2017 at 10:47 PM

Nice Blog. Thank you for Sharing. Enterprise Resource Planning Software Solutions in Chennai. For more details contact us info@bravetechnologies.in
erp in Chennai | erp software providers chennai

Evelin Harriet March 7, 2017 at 10:48 PM

I have read your blog its very Interesting. Thanks for sharing.
erp software solutions in chennai | erp software development company chennai

sivanesan March 20, 2017 at 11:10 PM

The best thing is that your blog really informative thanks for your great information!
erp providers in chennai

Alycia Christie March 23, 2017 at 7:42 AM


anitha a April 18, 2017 at 9:55 PM

Nice post. I have been reading a lot of stuff on this topic in the last few months, but this article stands out with its simplicity & authenticity. Every passage made profound sense. Thanks a lot for this.
Graphic design course in chennai

Riya R April 20, 2017 at 2:20 PM

Thank you for the informative post. It was thoroughly helpful to me. Keep posting more such articles and enlighten us.
SEO jobs in Hyderabad

deepti July 27, 2017 at 4:50 AM

Wonderful post. keep sharing..Web Designing Training Institute in Chennai | Web Designing Training Institute in Velachery.

NITROCOM August 22, 2017 at 12:24 AM

We are proud to have provided many services from previous generations
Racom microwave|Racom radio|Racom|Products racom|Racom dubai distributor|Racom uae distributor|racom communications|racom corporation|microwave Racom|buy and sell Racom|Shop Racom products|Racom Datasheet|Racom Products Support|Racom Device Installations|Racom radio Link Planning|Racom firmware update|Racom microwave Solutions|Racom uae agent

Post a Comment