Return to the menu   Select another DES Module

Demonstrates properties that determine when to display the ValidationSummary

The ValidationSummary control is displayed when the user attempts to submit the page and validation errors are found. Here are the properties that determine when to show it:

  • Group - The ValidationSummary control shows the error messages of Validators whose Group property matches the Group property on the submit control. If you want the ValidationSummary to display the errors from different groups, use a pipe (|) delimited list of group names or “*” for all groups.
  • AutoUpdate - Once the ValidationSummary control is shown, it can maintain the initial list of error messages or remove them as the user corrects them. When true, the errors are removed as they are corrected without posting back to the server. When false, the initial list of error messages remains until the user submits again.
  • AutoUpdateFirstShows – When AutoUpdate = true, this determines the first time the ValidationSummary appears. It usually appears after the user attempts to submit. Change it to appear after a certain number of errors are on the page.
  • ScrollIntoView – When the page is submitted and the ValidationSummary is shown, this scrolls the page on the client-side to show the ValidationSummary control. It has no effect on server side generation of this control.

Controls

Leave the textboxes blank and click Submit to see 3 errors in ValidationSummary controls below

First Name:
Last Name:
Postal Code:


Groups

Two ValidationSummary controls, each using a different validation group.


AutoUpdate

Fill in textboxes after first submitting with them empty. This ValidationSummary control will clear errors as you fix them.



AutoUpdate and AutoUpdateFirstShows

Click Reset to remove all text. This will show up without submitting, once there are two or more textboxes with errors. All expect only letters. So enter digits to get errors.



Source Code (C#)

<script runat="server">
protected void Button1_Click(object sender, EventArgs e) { if (PeterBlum.DES.Globals.WebFormDirector.IsValid) { // save your data here } }
</script> Leave the textboxes blank and click Submit to see 3 errors in ValidationSummary controls below<br/><br/> First Name: <des:TextBox ID="TextBox1" runat="server" /> <des:RequiredTextValidator ID="RequiredTextValidator1" runat="server" ControlIDToEvaluate="TextBox1" ErrorMessage="Required (using Group1)" SummaryErrorMessage="First Name is required" Group="Group1"> <ErrorFormatterContainer> <des:TextErrorFormatter Display="Dynamic" /> </ErrorFormatterContainer> </des:RequiredTextValidator> <des:CharacterValidator ID="CharacterValidator1" runat="server" ControlIDToEvaluate="TextBox1" ErrorMessage="Only letters and space (using Group1)" SummaryErrorMessage="First Name has illegal characters" LettersLowercase="true" LettersUppercase="true" Space="true" Group="Group1"> <ErrorFormatterContainer> <des:TextErrorFormatter Display="Dynamic" /> </ErrorFormatterContainer> </des:CharacterValidator> <br/> Last Name: <des:TextBox ID="TextBox2" runat="server" /> <des:RequiredTextValidator ID="Requiredtextvalidator2" runat="server" ControlIDToEvaluate="TextBox2" ErrorMessage="Required (using Group2)" SummaryErrorMessage="Last Name is required" Group="Group2"> <ErrorFormatterContainer> <des:TextErrorFormatter Display="Dynamic" /> </ErrorFormatterContainer> </des:RequiredTextValidator> <des:CharacterValidator ID="CharacterValidator2" runat="server" ControlIDToEvaluate="TextBox2" ErrorMessage="Only letters and space (using Group2)" SummaryErrorMessage="Last Name has illegal characters" LettersLowercase="true" LettersUppercase="true" Space="true" Group="Group2"> <ErrorFormatterContainer> <des:TextErrorFormatter Display="Dynamic" /> </ErrorFormatterContainer> </des:CharacterValidator> <br/> Postal Code:<des:TextBox ID="TextBox3" runat="server" /> <des:RequiredTextValidator ID="Requiredtextvalidator3" runat="server" ControlIDToEvaluate="TextBox3" ErrorMessage="Required (using Group1 and Group2)" SummaryErrorMessage="Postal Code is required" Group="Group1|Group2"> <ErrorFormatterContainer> <des:TextErrorFormatter Display="Dynamic" /> </ErrorFormatterContainer> </des:RequiredTextValidator> <des:CharacterValidator ID="CharacterValidator3" runat="server" ControlIDToEvaluate="TextBox3" ErrorMessage="Only digits and dash (using Group1 and Group2)" SummaryErrorMessage="Postal code has illegal characters" Digits="true" OtherCharacters="-" Group="Group1|Group2"> <ErrorFormatterContainer> <des:TextErrorFormatter Display="Dynamic" /> </ErrorFormatterContainer> </des:CharacterValidator> <br/> <des:Button ID="Button1" runat="server" Text="Submit - Group 1" OnClick="Button1_Click" Group="Group1"></des:Button> <des:Button ID="Button2" runat="server" Text="Submit - Group 2" OnClick="Button1_Click" Group="Group2"></des:Button> <input type="reset" id="Reset" runat="server" value="Reset" /> <hr/> <br/> <h2>Groups</h2> Two ValidationSummary controls, each using a different validation group.<br/> <des:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Fix these errors in Group 1" Group="Group1" /><br/> <des:ValidationSummary ID="ValidationSummary2" runat="server" HeaderText="Fix these errors in Group 2" Group="Group2" /><br/> <h2>AutoUpdate</h2> Fill in textboxes after first submitting with them empty. This ValidationSummary control will clear errors as you fix them.<br/><br/> <des:ValidationSummary ID="ValidationSummary3" runat="server" HeaderText="Fix these errors" Group="*" AutoUpdate="true" /><br/> <br/> <h2>AutoUpdate and AutoUpdateFirstShows</h2> Click Reset to remove all text. This will show up without submitting, once there are two or more textboxes with errors. All expect only letters. So enter digits to get errors.<br/><br/> <des:ValidationSummary ID="ValidationSummary4" runat="server" HeaderText="Fix these errors" Group="Group1|Group2" AutoUpdate="true" AutoUpdateFirstShows="TwoErrors" /><br/>

Return to the menu   Select another DES Module