ValidationAttribute.FormatErrorMessage(String) 方法

定义

基于发生错误的数据字段对错误消息应用格式设置。Applies formatting to an error message, based on the data field where the error occurred.

public:
 virtual System::String ^ FormatErrorMessage(System::String ^ name);
public virtual string FormatErrorMessage (string name);
abstract member FormatErrorMessage : string -> string
override this.FormatErrorMessage : string -> string
Public Overridable Function FormatErrorMessage (name As String) As String

参数

name
String

要包括在带有格式的消息中的名称。The name to include in the formatted message.

返回

String

带有格式的错误消息的实例。An instance of the formatted error message.

例外

当前属性格式错误。The current attribute is malformed.

注解

此方法使用属性对错误消息进行格式设置 ErrorMessageStringThis method formats an error message by using the ErrorMessageString property. 此方法将触发错误的数据字段的名称追加到格式化的错误消息中。This method appends the name of the data field that triggered the error to the formatted error message. 您可以通过创建一个重写此方法的派生类来自定义错误消息的格式化方式。You can customize how the error message is formatted by creating a derived class that overrides this method.

适用于