Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Using one customvalidator to validate multiple text controls

$
0
0

As 1 requiredfieldvalidator can't validate multiple text controls, I have to use one customvalidator.

But the question is how ?

I used OnServerValidate="CustomValidator1_ServerValidate" , but it doesn't seem to show error message, when I leave the fields totally blank.

then in behind .cs

protected void CustomValidator1_ServerValidate(object source,ServerValidateEventArgs args){

string text1=textcontrol1.Text;

string text2=textcontrol2.Text;

string text3=textcontrol3.Text;

if(text1==""||text2==""|text3=="")

args.IsValid=false;

else

args.IsValid=true;

}


Viewing all articles
Browse latest Browse all 23244

Latest Images

Trending Articles



Latest Images