Thursday, March 23, 2017

How to use multiple validators for one control at same place?

Let suppose I have a textbox for email and I want to validate that user must enter valid email address. In this statement there are two checks:
  1. User must enter email address – Required field
  2. Email address must valid email address
To do this two validator are required so it is required to use RequiredFieldValidator and RegularExpressionValidator both but the problem is that when we put these control adjacent to each other as below:
If we do this then email validation message shown far from the text box because RequiredFieldValidator still maintain their place.
Set the Display property to Dynamic on RequiredFieldValidator and RegularExpressionValidator. After doing this it render correctly.


No comments :

Post a Comment