Styling and Positioning Validation Messages

By default, the HTML that is produced by the validation controls is pretty basic, as shown in Listing 17-8.

Listing 17-8. The HTML generated by a validation control

<span id="RequiredFieldValidator1" style="display: none;">Enter a number of laps</span>

The error messages are expressed as span elements, and they are hidden from the user initially. If validation changes, then the JavaScript that the validation control adds to the page shows the span element to the user, revealing the error message. You can style the error messages that you display to the user either by setting a value for the CssClass property or by setting individual style properties in the property sheet. For all of the examples so ...

Get Applied ASP.NET 4 in Context now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.