所以我面临的问题是,我创建的 Remote 属性仅在它声明的字段发生更改时才会触发。但是当任何一个发生变化时,我都需要它来触发。
class MyViewModel
[Remote("ValidateTwoFields", "ControllerName", AdditionalFields = "Field2", ErrorMessageResourceName = "Errors_SomeErrorMessageThatShouldBeShowOnce", ErrorMessageResourceType = typeof(Resources.Resource))]
public string Field1{ get; set; }
public string Field2{ get; set; }
在控制器中:
//this only gets called when Field1 changes
//If I put the remote attribute on Field2 as well it displays the error message twice
public JsonResult ValidateTwoFields(MyViewModel model)
{
}