Export (0) Print
Expand All

ValidationAttribute.ErrorMessage Property

Gets or sets an error message to associate with a validation control if a validation fails.

Namespace:  System.ComponentModel.DataAnnotations
Assembly:  System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)

public string ErrorMessage { get; set; }

Property Value

Type: System.String
The error message associated with the validation control.

ExceptionCondition
InvalidOperationException

If a ValidationAttribute is already in resource mode or if you try to reset this property multiple times.

ArgumentException

If the value of the error message is an empty string or null.

This property is the explicit error message you associate with the validation control.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1

Community Additions

ADD
Show:
© 2015 Microsoft