在我的项目,我有一个模型,你可以在这里看到我的模型的一部分:验证错误:“对”的值无效<<属性名称>>
public class CheckoutModel
{
public bool OtherPlace { get; set; }
[RequiredIf("OtherPlace", true, ErrorMessage = " ")]
public string OtherPlaceFullName { get; set; }
[RequiredIf("OtherPlace", true, ErrorMessage = " ")]
public int OtherPlaceProvinceId { get; set; }
[RequiredIf("OtherPlace", true, ErrorMessage = " ")]
public string OtherPlaceCity { get; set; }
}
我用RequiredIf属性来验证我的模型看来,
if (!ViewData.ModelState.IsValid)
{
@Html.ValidationSummary(false)
}
我填我的表格的所有财产,但我得到下面的验证错误,当OtherPlaceProvinceId不填充。
值'on'对于OtherPlace无效。
UPDATE:控制器是在这里:
[HttpGet]
public ActionResult CheckoutAccount()
{
var model = OrderManager.Instance.GetCheckoutAccount();
return View("_CheckoutAccount", model);
}
[HttpPost]
public ActionResult CheckoutAccount(CheckoutAccountModel model)
{
return View("_CheckoutAccount", model);
}
你能张贴您的控制器? – mituw16
@ mituw16我张贴它。 – user3206982
@ mituw16你看到我的控制器了吗? – user3206982