BaseValidator::ErrorMessage Property
Gets or sets the text for the error message displayed in a ValidationSummary control when validation fails.
Assembly: System.Web (in System.Web.dll)
public: virtual property String^ ErrorMessage { String^ get () sealed; void set (String^ value) sealed; }
<asp:BaseValidator ErrorMessage="String" />
Property Value
Type: System::StringThe 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.
Implements
IValidator::ErrorMessageWhen 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.
Note |
|---|
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.
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. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note