System.Web.UI.WebControls Namespace BaseValidator Class
Sets or retrieves the text for the error message.
Inline |
<asp:validator errormessage = strText ... > |
Script |
Validator.ErrorMessage [ = strText ] |
strText |
String specifying the text to display when validation fails. |
The property is read/write with no default value.
Use the ErrorMessage property to specify the text to display in the validation control when validation fails. This text is also included in the ValidationSummary control, if one is placed on the Web page.
It is possible to display different text for the validation control and the ValidationSummary control. Use the Text property to specify the text to display in the validation control.
If the Text property ( inherited from the Label of the control ) contains a value, this message will overrride ErrorMessage and will be displayed at the location of the control if there is an error. However, the text specified by the ErrorMessage property always appears in the ValidationSummary control.
The following example demonstrates how to use the Text and ErrorMessage properties to differentiate the error messages for a RequiredFieldValidator and a ValidationSummary control on the same page.
Show me
BaseValidator Members Base Validation Control Properties Controlling Validation Message Display