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

備註

當您針對數據欄位設定 AllowEmptyStringstrue 時,動態資料不會執行驗證,並將空字串 null 轉換成值。 這個值接著會傳遞至資料庫。

如果資料庫不允許 null 值,則會引發錯誤。 若要避免這個錯誤,您也必須將 ConvertEmptyStringToNull 設定為 false

適用於