asp.net.ph

Skip Navigation Links

Controlling Validation Message Display

ASP.NET Web Forms   Web Forms Server Controls   Web Forms Validation


You can display validation error messages in four ways:

Display Option Description
In-line At the position where the validation control is declared.
Summary In a separate summary of all errors. Optionally, the errors can appear in a pop-up message box.
In-line and summarized In that case, the error message can be different in the summary and inline. You can use this option to show a shorter error message inline with more detail in the summary, or to show an error glyph next to the input field and an error message in the summary.
Custom You can create your own error message display. For details, see Displaying Custom Error Messages.

You can also specify the format and layout of error messages. For details, see Formatting Validation Error Messages.

If you want to display summarized or pop-up error messages, you need to add a control to the page.

To add summarized error messages

  1. Add a ValidationSummary control to the page at the location where you want to display the collected error messages.
  2. Set the summary control’s DisplayMode property to format the error messages, using one of the following values defined in the ValidationSummaryDisplayMode enumeration:

BulletList Each message appears in a bullet list. ( This is the default. )
List Each messages appears on its own line.
SingleParagraph Each message appears as a sentence in a paragraph. Optionally set the control’s HeaderText property to provide a title or header for the error messages.

Choosing inline and summary display involves setting different combinations of properties in the individual validation controls.

To choose in-line and summary error display

  1. If you want to display summary errors, add a ValidationSummary control as described in the procedure above.
  2. Set the ErrorMessage, Text, and Display properties of the individual validation controls according to the following table:

Option ValidationSummary control Property settings on validation control
Inline only not required Display = Static or Dynamic

ErrorMessage or Text = inline text

Summary only required Display = None

ErrorMessage = summary text

Inline and summary required Display = Static or Dynamic

ErrorMessage = summary text

Text = inline text

Summarized error messages can also appear in a pop-up window.

To display summarized error messages in a pop-up window

  • Set the ShowMessageBox property of the ValidationSummary control to true.

When the user submits the page, errors are displayed in both the summary control and in the pop-up window. If you do not want the errors to be displayed in the summary control ( only in the pop-up message box ), set the ShowSummary property to false.

NOTE: The option to use a pop-up message box is available only if the user is using a DHTML-compatible browser ( Internet Explorer® 4.0 and later ) .

See Also

Formatting Validation Error Messages   Specifying Error Mesage Layout   Displaying Custom Error Messages   Data Entry Validation ( Client-Side )



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note