Question

So I have 2 buttons, 2 RequiredFieldValidator and 2 validation summary that triggers to the RequiredFieldValidator. How do I make 1 button to perform a validation for the let's say validator1 and another button to perform another validation by the validator2 and displays its result with their own separated validation summary?

In my masterpage, I wrap my contentplaceholder1 with a runat server form. In that contentplateholder1, is my 2 separated form that requires the 2 individual form inputs

Was it helpful?

Solution

You can group these controls for validation purposes by setting the ValidationGroup property. If you set button1's ValidationGroup property to "group1"...

 <asp:Button ValidationGroup="group1" ...></asp:Button>

Then, all validation controls that belong to the same group will perform user input validation when this button is clicked. Here's an example of how set the validation group for validation controls...

<asp:ValidationSummary ValidationGroup="group1" ...></asp:ValidationGroup>
<asp:RequiredFieldValidator ValidationGroup="group1" ...></asp:RequiredFieldValidator>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top