次の方法で共有


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 any 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 they 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 has a browser that supports dynamic HTML (DHTML), 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:

Layout Option

Description

Static

Each validation control takes up space even when no error message text is visible, enables you to define a fixed layout for the page. Multiple 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 and later; in other browsers the layout effectively becomes Dynamic.

Dynamic

Validation controls take up no space unless they are displaying an error message, which enables 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 a browser that supports dynamic HTML (DHTML). If your Web application will be used with browsers that do not support DHTML, it is advisable instead to lay out the validation controls in a table cell or a Panel control.

See Also

Tasks

How to: Specify Layout for In-Place Messages On ASP.NET Server Controls

Other Resources

ASP.NET Validation Controls