有没有办法在ASP.NET MVC回发期间删除ModelState错误,而无需手动编写每个错误.
假设我们有一个复选框Billing Same As Shipping,然后我们想忽略用户在签署ShippingAddress时所写的内容 – 通常你可能会这样做.
ModelState.Remove("Checkout.ShipppingAddress.FirstName"); ModelState.Remove("Checkout.ShipppingAddress.LastName"); ModelState.Remove("Checkout.ShipppingAddress.Address1"); ModelState.Remove("Checkout.ShipppingAddress.Address2"); ... ModelState.Remove("Checkout.ShipppingAddress.ZipCode");