When using ASP.NET validation controls, you can control the formatвЂ”font, size, and so onвЂ”of error text, or you can substitute a marker for error text. For example, you can have the validation control display an asterisk (*) when an error occurs.
Using a marker in place of text can detract from the accessibility of the page. For more information, see ASP.NET Accessibility.
You can also include a detailed error message in the property of the validation control and add a control to the page. The detailed ErrorMessage property text will appear on the page in the location of the ValidationSummary control.
You can provide formatting within an error message by using HTML elements in the text for the ErrorMessage and properties. For example, to apply italics to only one word in the error message, you can enclose the word in <i> and </i> tags.
To display reserved HTML characters within the error message text, encode them. For example, to display "<", use the character sequence <.
If you are displaying validation errors in a summary, you can specify that a marker appear in place of the individual validation control.
To format error messages
Set validation control properties such as the following:
The color of the error message text.
The color behind the text.
The font face, size, weight, and so on.
, , and
The size and color of a border around the error message.
Style settings that are used if the user is working with a browser that supports CSS style sheets.
Some of the settings you make with these properties may not be supported in all browsers.
To display markers next to input controls
Set the ErrorMessage property of each validation control to the error text that should appear in the ValidationSummary control.
Set the Text property of each validation control to the marker to display. The marker can consist of any valid HTML, including text (such as an asterisk) or an image.
The marker is displayed in place of the validation control. It is up to you to lay out the validation control in such a way that the marker displays properly.