asp.net.ph

Skip Navigation Links

Specifying Error Message Layout

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


When an error message appears on the page, it becomes part of the layout of the page. You need to design the layout of your page to accommodate error text that might appear.

If validation is being performed on the server, validation controls are not even rendered to the page unless an error occurs and therefore take up no space whatsoever. If an error has occurred, the page is recreated during the round trip and the error text is flowed to the page.

If the user is using a DHTML-compatible browser, validation occurs on the client dynamically. In that case, inline error message text appears immediately and can potentially change the layout of the page.

To control how error message text is displayed with client validation, you can set the Display property of validation controls to one of three options:

To specify fixed or dynamic layout for client error messages

  • Set the Display property of each validation control to a layout option defined by the ValidatorDisplay enumeration:

Layout Option Description
Static layout Each validation control takes up space even when no error message text is visible, allowing you to define a fixed layout for the page. In this case, though, the error messages of validation controls cannot occupy the same space on the page; each appears on a separate location, which by default is where the control is declaratively set on the page.
Dynamic layout Validation controls take up no space unless they are displaying an error message, which allows them to share the same location on the page. However, when the error message is displayed, the layout of the page changes, and may cause controls to change positions.
None The validation control does not appear on the page.

NOTE: Static and Dynamic layout requires that the browser support the CSS visible style attribute ( Internet Explorer 4.0 or later ) . If your Web application will be used with browsers that might not support that attribute, it is advisable instead to lay out the validation controls in a Panel control that is large enough to accommodate the largest possible error message.

See Also

Controlling Validation Message Display   Formatting Validation Error Messages   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