I ask a similar question here. This is My Model:
[DisplayName("National Code")]
[Required(ErrorMessage = "Required")]
[RegularExpression(CustomRegex.SSNRX, ErrorMessage = CustomRegex.SSNErMsg)]
[Remote("DBValidateSSN", "CustomerProfile", "Members", ErrorMessage = "Repeated.")]
public string SSN { get; set; }
So I use a Generic Class as a Model And My View is like:
@Html.EditorFor(model => model.MainModel.SSN)
@Html.ValidationMessageFor(model => model.MainModel.SSN)
And Validate Action:
public JsonResult DBValidateSSN([Bind(Prefix = "MainModel")] string SSN) {
// ....
return Json(result, JsonRequestBehavior.AllowGet);
}
But the SSN parameter in action is always null, where is my fault? what is the problem I also check Ajax Request Params in FireBug and name used is MainModel.SSN
, what is your suggestion?