BaseValidator::ErrorMessage Property

 

Gets or sets the text for the error message displayed in a ValidationSummary control when validation fails.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public:
property String^ ErrorMessage {
	virtual String^ get() sealed;
	virtual void set(String^ value) sealed;
}

Property Value

Type: System::String^

The error message displayed in a ValidationSummary control when validation fails. The default value is an empty string (""), which indicates that this property is not set.

When using a ValidationSummary control, use the ErrorMessage property to specify the text to display in the ValidationSummary control when validation fails for the current validation control. To specify the text to display in the validation control itself, use the Text property.

System_CAPS_noteNote

If you set the ErrorMessage property without setting the Text property, the value of the ErrorMessage property is also displayed in the validation control.

The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and ASP.NET Globalization and Localization.

The following code example demonstrates how to use the ErrorMessage property to specify different messages for the ValidationSummary control and the RequiredFieldValidator and CompareValidator controls.

System_CAPS_security Security Note

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: