Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate validators


If I have more than one asp.net server validator on the same control,
(Suppose that both of them can return false in a specific situation) and I want to display only one message (Except the validation summary),
How can I Achieve this goal and group the Text property of all the validators that link to the same control?

If I Implement this situation I receive in the output the Text attribute of each one of the validators...

like image 538
liron Avatar asked Apr 26 '11 12:04

liron


1 Answers

Put these two validators control in seperated ValidationGroup and create a new Custom Validator that checks these two validators controls with unified message.

protected void CustomValidator (object sender, ServerValidateEventArgs e)
{
    e.IsValid = validator1.IsValid && validator2.IsValid
}
like image 134
Homam Avatar answered Oct 04 '22 20:10

Homam