Validation Error Message Layout for ASP.NET Server Controls
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 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 added to the page.
If the user is using a DHTML-compatible browser, validation occurs dynamically on the client. In that case, in-place 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:
|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. Validation controls cannot occupy the same space on the page, so you must give them each separate locations on the page. This setting only works in Internet Explorer 4.0 or later; in other browsers the layout effectively becomes Dynamic.|
|Dynamic layout||Validation controls take up no space unless they are displaying an error message, which allows them to share the same location (a table cell, for example). However, when the error message is displayed, the layout of the page changes, sometimes causing controls to change positions.|
|None||The validation control does not appear on the page.|
Note Dynamic layout requires Internet Explorer 4.0 or later. If your Web application will be used with other browsers, it is advisable instead to lay out the validation controls in a table cell or a panel control that is large enough to accommodate the longest possible error message. (For more information see Panel Web Server Control.)