Free Training


C Language  |  CSS  |  MainFrame  |  VBScript  |  PHP  |  XML  |  C++ Tutorials  |  Ajax  |  JavaScript  |  CSS3  |  UML  |  jQuery  |  Microsoft AJAX

VB.NET 2005 Tutorials

 
Home Tutorials VB.NET 2005
 

VB.NET Validation Controls

 

VB.NET Validation Controls - Page 2

Page 2 of 3

.
.
.



Error Provider

The Windows Forms ErrorProvider component is used to validate user input on a form or control. It is typically used in conjunction with validating user input on a form, or displaying errors within a dataset. An error provider is a better alternative than displaying an error message in a message box, because once a message box is dismissed, the error message is no longer visible. The System.Windows.Forms.ErrorProvider component displays an error icon ( ) next to the relevant control, such as a text box; when the user positions the mouse pointer over the error icon, a ToolTip appears, showing the error message string.

Let us see an example for CausesValidation and also ErrorProvider in the following illustration:


  1. Create a new project in the Visual Studio IDE and
  2. Add two text boxes to the Form1.
  3. Check to see if the default value of the causes validation is set to true. This means that when the either text box receives the focus, it will cause all the other controls validating events to occur.
  4. Add an error provider object from the toolbox. You will see the window like the one in the screenshot below:


  1. Now add the following code
    Click here for Sample Code


  2. Now press F5 to execute the application. The following three screenshots will show the output and the error messages.



The following screenshot shows the message box shown by the exception handler in response to the event validating when no data entered in the text box:




The following screenshot shows the message box displayed by the exception handler in response to the EventValidating when text data is entered in the text box.


The following screenshot shows the message box displayed by the exception handler in response to the EventValidating when text data is entered in the text box.




Next Page: VB.NET Validation Controls - Page 3


Read Next: VB.NET Creating and Managing Components Part 1



 

 

Comments


jaber_souqi said:

  Can I have more about The validation with ASP.NET 2.0
September 6, 2006, 5:28 am

ereemye said:

  Really good. But i have a problem with creating crystal reports. i used a wizard but it only displays the field titles with out the a vailable information in the database. Now i know am asking the right guy
i will be very happy
October 2, 2006, 2:35 am

kushal kanal; said:

  well .. i have readed the vb.net validation examples and i was impressed by the article which was putted on it ...
now i have learnt how to validated the fields in the project ...

well .. now i wanna like 2 know ... the registration form 's fields validation like a password ... etc... if any one knows it ... plz mail me the code of the registeration form validation on the rajahuja18@gmail.com
October 16, 2007, 4:01 am

Omar said:

  Thanks for the article on validation, the article helped very much. But I want to find out how to do d same procedure with radio buttons and combo box. Where the system forces the user to input correct values.
March 12, 2008, 8:30 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Weekly Offers

Sponsored Links