When you delete a custom check on your page, you can associate the validator with the control, but if you want to perform multiple checks on more than one control, you need to include the following attribute
OnServerValidate="MyMethodOnServerSide"
and define this method on the server side
protected void MyMethodOnServerSide(object source, ServerValidateEventArgs args) { if (string.IsNullOrEmpty(mytxt1.Text) && string.IsNullOrEmpty(mytxt2.Text)) { args.IsValid = false; return; } args.IsValid = true; }
just set the args.IsValid property args.IsValid value you need. On the other hand, the check is performed before you load the page, so if you clicked on a button that performs an action such as reading values ββfrom the database, if everything is correct, in this step you need to include the following check.
protected void cmdSearch_Click(object sender, EventArgs e) { if (Page.IsValid) { LoadDataFromDB(); } }
When args.IsValid is false, then Page.IsValid also false. Hope this helps
Zinov source share