Figure : Error Provider Sample
The complete code listing is provided at the end of the sample.
Create a new Visual C# Windows Forms application. The project will create a default form Form1.cs. Add controls as shown in the figure below and set the properties of the controls as indicated in the table.
Figure : Sample Form Layout
Table : Properties for Sample Form Layout Controls
Now add a ErrorProvider control to the Form. In Visual Studio.Net, you can drag and drop the control from the toolbox. The control is added to the form and displayed in the control tray in the Windows form in Design view. If you are not using Visual Studio.Net, then you can add the control in the code. Please refer to the code listing provided at the end of the article.
Now create an event handler for the “Validating” event of the textBox1 control. We will validate the TextBox to ensure that the user has entered a value.
Code Snippet: Validate the Name TextBox
Next we will add the validations for the textBox2 control which accepts Age as the data input. We will ensure that the Age is mandatory, is in numeric format and the user is 18 years or older.
Read the Full Article
About the Author:
Dipal Choksi is a Bachelor of Engineering (Computer Science). She has industry experience in team-effort projects and also as an individual contributor. She has worked on Visual Basic, Visual C++, Java, Directory Services, ASP projects
Read this Newsletter at: http://www.cprogrammingtrends.com/2004/0407.html |
|
| From
the Forum: |
| script for timed website |
| Hello, I really enjoy reading the messages posted here. I am wondering if someone can help me. I have a password protect area on a web site (created with Front Page) and I want this site to close all windows after a certain amount of time. I now have a redirect after 5 minutes but someone can easily hit the back button and get right back to the "secured" area.
|
|