RequiredAttribute.AllowEmptyStrings 屬性

定義

取得或設定一個值,指示是否允許空字串。

public:
 property bool AllowEmptyStrings { bool get(); void set(bool value); };
public bool AllowEmptyStrings { get; set; }
member this.AllowEmptyStrings : bool with get, set
Public Property AllowEmptyStrings As Boolean

屬性值

true若允許空字串;否則,。 false 預設值為 false

備註

當你設定 AllowEmptyStrings 為 資料 true 欄位時,動態資料不會進行驗證,而是將空字串轉換成一個 null 值。 這個值隨後會傳入資料庫。

如果資料庫不允許 null 值,就會產生錯誤。 為避免此錯誤,你也必須將 設定 ConvertEmptyStringToNullfalse

適用於