ここで同様の質問をします。これは私のモデルです:
[DisplayName("National Code")]
[Required(ErrorMessage = "Required")]
[RegularExpression(CustomRegex.SSNRX, ErrorMessage = CustomRegex.SSNErMsg)]
[Remote("DBValidateSSN", "CustomerProfile", "Members", ErrorMessage = "Repeated.")]
public string SSN { get; set; }
だから私はジェネリッククラスをモデルとして使用し、私のビューは次のようになります:
@Html.EditorFor(model => model.MainModel.SSN)
@Html.ValidationMessageFor(model => model.MainModel.SSN)
そして検証アクション:
public JsonResult DBValidateSSN([Bind(Prefix = "MainModel")] string SSN) {
// ....
return Json(result, JsonRequestBehavior.AllowGet);
}
しかし、動作中の SSN パラメータは常に null です。どこに問題があるのでしょうか? FireBug で Ajax Request Params もチェックしていますがMainModel.SSN
、使用されている名前は です。あなたの提案は何ですか?