User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 374,572 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,848 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
May 15th, 2008
Views: 1,078
Checking whether value is entered into a control and preventing focus to go out if no value is entered.
csharp Syntax
  1. private void txtName_Validating(object sender, CancelEventArgs e)
  2. {
  3. if (txtName.Text == "")
  4. {
  5. errorProvider1.SetError(txtName, "Name cannot be blank");
  6. e.Cancel = true;
  7. }
  8. else
  9. errorProvider1.SetError(txtName, "");
  10. }
Comments (Newest First)
bruceraymond | Newbie Poster | Jun 15th, 2008
C# has internal parsing routines that also work nicely.

Cheers,
Bruce


double x;
bool valid = double.TryParse( initialValue.Text, out x );
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 5:54 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC