My issue is similar to:
Compound View Model object causing remote validation failure
My models:
public class Address
{
public string Street { get; set; }
public string City { get; set; }
[Remote("CheckZip", "Validation")]
public string PostalCode { get; set; }
public string Country { get; set; }
}
public class OrderViewModel
{
public Address ShippingAddress { get; set; }
public Address BillingAddress { get; set; }
public string OrderItem { get; set; }
public string OrderQuantity { get; set; }
}
The rendered HTML creates the fields ShippingAddress_Postalcode and BillingAddess_PostalCode.
The CheckZip action:
public ActionResult CheckZip (string PostalCode)
{
...
}
which of course doesn't work because PostalCode isn't being sent instead its either ShippingAddress_Postalcode or BillingAddess_PostalCode. How can I use the same CheckZip action to handle the same sub-property that exists in multiple properties?