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.

適用於