Duration: 22 minutes
Summary: In this video, we start our discussion on validation controls. We explain the need of these controls and their importance for data validation. Any control with the ValidationProperty attribute can have its data validated using the validation controls. These controls validate the data on the client side and the server side. We can turn off the client validation by setting the EnableClientScript property on the validation control to false. The example we create in this case uses the RequiredFieldValidator to make sure the user enters data for the name and the quantity. Then we add the CompareValidator to make sure the user enters a numeric value for the quantity. To associate the control with its validation control, we set the ControlToValidate property. We set the Text property to “[Required]”, and that is what will display to the user if he/she does not enter a value in the associated control. For the Display property there are two values “static” (the default) and “dynamic”. For the static value the control will take the space, but not visible. For the dynamic value the control will have a display property of “none” meaning that it does not even take a space on the page.
Methodology of the development of example: Good coding standard and simplified design to illustrate the key points.
Technology Used: ASP.NET and Visual Studio 2010Keyword: ASP.NET 4, Visual Studio 2010, static, dynamic, RequiredFieldValidator, CompareValidator, EnableClientScript, ValidationProperty, IsValid, ControlToValidate, Operator, Type