Click here to Skip to main content
15,040,212 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have a windows application form in vs 2010 using c#, In this I have 34 textboxes and a save button. I am using Ms Accesd database for inserting these values in database.
These values are storing Successfully when i click on Submit button.
Till here, it is working fine. now my requirement is:

If i click on save button and if the textboxes are empty, it must display a message "please enter the required fields."
if the textboxes are filled with data then, when i click the submit button this should be displayed: "Are you sure you want to Save this data ?"
if Successfully stored in DB, Display a message... Successfully Submitted.
Updated 27-Jun-18 17:18pm
Maciej Los 31-May-15 15:41pm
What have you tried? Where are you stuck?

1 solution

If you want to check them all it's pretty simple:
bool ok = true;
foreach (Control c in Controls)
   TextBox tb = c as TextBox;
   if (tb != null && string.IsNullOrWhitespace(tb.Text))
      ok = false;
if (!ok)
   // Report the problem

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900