共用方式為


ModelClientValidationRule.ErrorMessage Property

Gets or sets the error message for the client validation rule.

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Syntax

'Declaration
Public Property ErrorMessage As String
    Get
    Set
public string ErrorMessage { get; set; }
public:
property String^ ErrorMessage {
    String^ get ();
    void set (String^ value);
}

Property Value

Type: System.String
The error message for the client validation rule.

Examples

The following example shows how the ModelClientValidationRegexRule constructor sets the error message and validation type, and how it adds a regular expression rule.

public class ModelClientValidationRegexRule : ModelClientValidationRule {
    public ModelClientValidationRegexRule(string errorMessage, 
            string pattern) 
    {
        ErrorMessage = errorMessage;
        ValidationType = "regularExpression";
        ValidationParameters.Add("pattern", pattern);
    }
}
Public Class ModelClientValidationRegexRule 
    Inherits ModelClientValidationRule
    Public Sub New(ByVal errMessage As String, ByVal pattern As String) 
        ErrorMessage = errMessage 
        ValidationType = "regularExpression" 
        ValidationParameters.Add("pattern", pattern) 
    End Sub 
End Class

See Also

Reference

ModelClientValidationRule Class

System.Web.Mvc Namespace