Tag Archives: Validation Controls in ASP.NET

ValidationSummary control in ASP.NET

ValidationSummary sever control in ASP.NET displays all the validation errors on the page at one place. ValidationSummary displays ErrorMessages of all the validation controls which fail to validate as summary Properties of ValidationSummary control Property Uses DisplayMode Gets or sets display mode of the ValidationSummary control. It can be set to BulletList, List or SingleParagraph.… Read More »

Using server-side validation in ASP.NET CustomValidator control

In this post I will explain how to use CustomValidator server control for server-side validation. Using server-side validation, CustomValidator can take advantage of power of the server-side languages C#, VB etc. For example, we can validate an input control’s value using data from the database. In the following example we will see how to validate… Read More »

Using client-side validation in ASP.NET CustomValidator control

CustomValidator server control in ASP.NET is used to validate an input control using a custom function. It provides programmer with the flexibility to use a custom function for validating an input control. CustomValidator can validate a control using a server-side function or a client-side function. Server-side function is written in server side language like Visual… Read More »

RegularExpressionValidator in ASP.NET

RegularExpressionValidator validation control in ASP.NET validates a control according to the regular expression (RegEx) set to its ValidationExpression property. Using this validation control we can specify a format of data that a control should accept using a RegEx. For example, we can validate a Phone number, Email, Zip Code etc using a RegularExpressionValidator control. Properties… Read More »

Validating list controls in ASP.NET using RequiredFieldValidator

RequiredFieldValidator control can be used to validate ASP.NET list controls like DropDownList, ListBox and RadioButtonList so that they cannot be left blank. Users must select a value from these list controls when validation has been applied. To validate a list control, we need to set InitialValue property of the RequiredFieldValidator along with other properties. Let… Read More »

How to avoid space occupied by an inactive validation control in ASP.NET

A validation control occupies space even if it is not showing any error. This is because by default Display property of the validation control is set to Static. For example, if we take two validation controls, one RequiredFieldValidator and one RangeValidator and if any of the validation fails, both the validation controls will consume their… Read More »

RangeValidator control in ASP.NET

RangeValidator validation control in ASP.NET is used to validate whether the value of a control is in a given range. It can validate Currency, Date, Double, Integer and String value. Properties of RangeValidator control Property Uses ControlToValidate It takes ID of the control you want to validate Type It specifies the type of data you… Read More »

CompareValidator control in ASP.NET

CompareValidator validation control in ASP.NET is used to validate an input control’s value by comparing it with another control’s value or a constant value. For example, we can use CompareValidator to validate controls if we want user to enter same value in two different controls, to compare value of a control with another control, to… Read More »

Validation controls in ASP.NET

Data validation is very important while accepting input from user. There may be different business logic for validating data. Some basic validation would be to validate a field to accept only numbers or a valid email address or phone number of a country in a specific pattern etc. ASP.NET provides some built-in controls for this… Read More »