0
私はビューに対してクライアント側の検証を使用しており、組織オブジェクトとアドレスオブジェクトを含むViewModelを作成しました。ASP.NET MVC 3リモート検証が動作を停止しました
私は以前、ドメインエンティティにマップされたViewModelを持っていました。
[NotMapped]
[Remote("ValidOrganisation", "Manage", "Organisations", ErrorMessage = "That organisation doesn't exist")]
public string Organisation { get; set; }
はしかし、私は今、以下を含むビュー用のViewModelを作成しました:
public class PersonModel
{
public Person Person { get; set; }
public AddressModel Address { get; set; }
}
人物オブジェクトが組織のプロパティが含まれている自分のドメインエンティティに私は次のようでした。私の見解では
は、私は次のようしている:
<div>
<label for="Organisation">Organisation</label>
<div class="input large">
@Html.TextBoxFor(m => m.Person.Organisation)
<span class="help-block">Type the first letter of the organisation to search</span>
@Html.ValidationMessageFor(m => m.Person.Organisation)
@Html.Hidden("OrganisationID")
</div>
</div>
た変更だけの事:
@Html.TextBoxFor(m => m.Organisation)
へ:
@Html.TextBoxFor(m => m.Person.Organisation)
私のリモート検証コードは次のとおりです。
public JsonResult ValidOrganisation(string organisation)
{
var exists = orgs.SelectAll().Where(o => o.Name.ToLower() == organisation.ToLower()).Count() > 0;
return Json(exists, JsonRequestBehavior.AllowGet);
}
問題は、NULLが常に渡され、常にfalseを返すことです。
これは、組織プロパティがPerson.Organisationに変更されたことと関係していますか?
私はそれを試みましたが、Person_Organisationは常にNULLです。 IDはPerson_Organisationで、名前はPerson.Organisationで、テキストボックスのinspect要素です。 – Paul
FireBugを使用して、どのURLと値がサーバーに送信されたのか教えてください。 – swapneel
アドバイスをいただきありがとうございますが、私は少しでもアプリケーションの再組み立てを行いました。私はまだあなたが上記で指定した方法を使用して動作することを拒否した理由を知りませんが。 – Paul