1 / 38

Working with Validation Controls

Working with Validation Controls. What is Validation Controls? Why we should use them?

callia
Download Presentation

Working with Validation Controls

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Working with Validation Controls

  2. What is Validation Controls? • Why we should use them? • Lots of questions are take place in your mind now hear is the solution for it. Validation Controls name suggest that it is related to validate something but yet it is not clear that what we should validate. Answer is that when you create any form in your application. There should have several restrictions regarding your requirement

  3. For Example: • When you create a form for Personal Information below thing should be validate before you add this value in to database. • Name should not be Blank. • Age should be in number. • Age should be in between numeric range. • Email, Pin code should be in specific format etc.

  4. These types of Validations are used when we create forms. Now it’s little bit clear in your mind that why we use Validation control but how to validate them is not clear. It can be done through two ways • Client Side Validation. • Server Side Validation.

  5. What is Client Side Validation? • Client Side Validation can be done through JavaScript. The Advantages of the client side validation is that it should not make round trip to server that will validate through your browser so it will take less time than server side validation.

  6. What is Server Side Validation? • while when we use server side validation that will make a round trip to server and than give call back that whether it is validate or not means this will take a more time than client side validation. • But it is more secure than client side validation because some time if your browser will not support some version of JavaScript than it will not validate perfectly while here in that case we are secure because this will defiantly occur.

  7. Client Side Validation vs Server Side Validation: Client Side Validation: • Client Side validation will occur in Browser. • Client Side validation will take less time for execution. • Client side validation is not secure as server side. • Client side validation will not work if your browser will not support JavaScript.

  8. Server Side Validation:  • Server Side validation will occur in Server. • Server Side validation will take more time than client side execution. • Server side validation is more secure than Client side validation. • Server side validation will always execute because it is not depended on browser.

  9. Asp.Net Validation controls: • Asp.Net Provide the validation control to validate your form in both way client side Validation as well as server Side Validation. If the user is working with a browser that supports dynamic HTML (DHTML), ASP.NET validation controls can perform validation using client script. Because the controls can provide immediate feedback without a round trip to the server, the user experience with the page is enhanced.

  10. The controls automatically detect if the browser supports DHTML and perform their checking accordingly.

  11. With ASP.NET, there are six validation controls included. They are: • The RequiredFieldValidation Control. • The CompareValidator Control. • The RangeValidator Control. • The RegularExpressionValidator Control. • The CustomValidator Control. • Validation Summary Control

  12. RequiredFieldValidator : • RequiredFieldValidator control is used in a web form to check whether a control has a value. Typically, we use this control with a TextBox control. However, it can also use with other control such as RadioButton, CheckBox etc.

  13. Example: Do the following steps. Take following items from the ToolBox. • A Label • A TextBox • A Button • A Require Field validator control and put it near to TextBox

  14. Set the following property of above controls.

  15. After set all property as shown in above Table click on add button if you are not fill the value in textbox bellow error message will show.

  16. RequiredfieldValidator control Properties:

  17. CompareValidator : • The CompareValidator control is use for the purpose of comparison of two fields that can be values of textbox , radio button or dropdown list etc. in short you can compare two values. If that will not match than it will raise the error.

  18. Example : • Do the following steps. • Take following items from the ToolBox. • 1) Two Label. • 2) Two TextBox. • 3) A Button. • 4) A Compare Field validate control.

  19. Set the following property of above controls.

  20. After set all property as shown in above Table click on Compare button if you are not fill the value in textbox bellow error message will show.

  21. CompareValidator control Properties:

  22. RangeValidator Control • This control is use to check whether the value of a form field are between a minimum and maximum value. The minimum and maximum values can be dates, number currency amounts or strings

  23. Example : • Do the following steps. • Take following items from the ToolBox. • 1) Two Label. • 2) Two TextBox. • 3) A Button. • 4) A RangeValidator Control. • Set the following property of above controls.

  24. After set all property as shown in above Table click on Submit button if you are not fill the value in textbox bellow error message will show.

  25. RangeValidator control Properties:

  26. RegularExpressionValidator : • This validation control use to match the value entered into a form field to a regular expression. You can use this control to check whether a user has entered, for example a valid-Email address, telephone number, or username or password.

  27. RegularExpressionValidator controlProperties:

  28. CustomValidator Control : • CustomValidator name suggest its meaning. By default what kind of validation you require that can not be judged all the time so Microsoft .Net provide the facility of custom validation. Here you can create your own custom validation according to your requirements.

  29. Validation Summary Control: • Assume that there are more than thirty fields in your form. If you use validation controls for displaying error that it will be difficult for the any user to read it out so to solve this problem Microsoft add new validation control which is known as validation summary control. It’s name reflected its meaning. This control will show the list of the error message of your form so that it should be easy to see the error and use can fill form perfectly.

More Related