There are two things.
- First in CustomValidator1_ServerValidate method, set the
args.IsValid = false;
if validation fails. This indicates whether the validation is failed or not. You are just showing error but not making page status invalid.
- Second, add additional check for
Page.IsValid
before inserting record in DB. It checks whether all the validation on the page is passed or not.