如何在表单上提供所有字段之前抑制 asp.net mvc 远程验证?
How to suppress asp.net mvc remote validation until all fields provided on form?
我有一个具有以下属性的模型:
public class AddAdsItemViewModel
{
[Remote("AdsItemExist", "AdsItem", "Administrator", ErrorMessage = "Already Exists.", HttpMethod = "POST", AdditionalFields = "AdsTypeId, AdsSizeId, PublishTypeId, OsTypeId, DeviceTypeId")]
public string Name { get; set; }
public int AdsTypeId { get; set; }
public int AdsSizeId { get; set; }
public int PublishTypeId { get; set; }
public int OsTypeId { get; set; }
public int DeviceTypeId { get; set; }
}
我的问题是,当我填写 Name 属性 的文本框并且文本框失去焦点时,会调用远程验证,并且其他属性将为 null !!
这是因为表单上的其他字段仍未填写,我想在表单上提供所有属性之前禁止远程调用验证。
这个问题有什么解决办法吗?
更新:
我通过以下 link 找到了解决方案:
Multiple fields validation using Remote Validation
我有一个具有以下属性的模型:
public class AddAdsItemViewModel
{
[Remote("AdsItemExist", "AdsItem", "Administrator", ErrorMessage = "Already Exists.", HttpMethod = "POST", AdditionalFields = "AdsTypeId, AdsSizeId, PublishTypeId, OsTypeId, DeviceTypeId")]
public string Name { get; set; }
public int AdsTypeId { get; set; }
public int AdsSizeId { get; set; }
public int PublishTypeId { get; set; }
public int OsTypeId { get; set; }
public int DeviceTypeId { get; set; }
}
我的问题是,当我填写 Name 属性 的文本框并且文本框失去焦点时,会调用远程验证,并且其他属性将为 null !!
这是因为表单上的其他字段仍未填写,我想在表单上提供所有属性之前禁止远程调用验证。
这个问题有什么解决办法吗?
更新:
我通过以下 link 找到了解决方案:
Multiple fields validation using Remote Validation