컨테이너와 중첩 된 뷰 모델이 있고 중첩 된 뷰 모델을 렌더링하는 EditorFor를 사용하여 하나의 viewmodel (ConcreteViewModelA :: prop3)의 속성 중 하나에 대한 유효성 검사를 위해 remoteAttribute를 추가하려고합니다. 그러나 유효성 검사 컨트롤러 동작 메서드에서 얻을 수있는 모든 null입니다.접두사가있는 RemoteAttribute
Validate ([Bind (접두어 = "item")] string prop3)를 사용했지만 속성을 사용하려고했으나 여전히 NULL로 되돌아 왔습니다. 어떤 아이디어?
public class SomeContainer
{
public List<ISomethingViewModel> SomeViewModels { get; set; }
}
public class ConcreteViewmodelA : ISomethingViewModel
{
public int prop1 { get; set; }
public int prop2 { get; set; }
[Remote("Validate", "RemoteValidation")]
public string prop3 { get; set; }
}
public class ConcreteViewModelB : ISomethingViewModel
{
public int prop1 { get; set; }
public int prop2 { get; set; }
}
public interface ISomethingViewModel
{
int prop1 { get; set; }
int prop2 { get; set; }
}
보기 :
@model test.Models.SomeContainer
@using (Html.BeginForm())
{
@Html.ValidationSummary()
<p>Begin here</p>
foreach (var item in Model.SomeViewModels)
{
@Html.EditorFor(x => item)
}
}
나는이 사용하는 작업을 얻을 수있었습니다을 읽을 같은 것을 할 수있는이
Validate?item.prop3=
처럼 보인다 Prefix = "item")] ConcreteViewmodelA vm3) – user965160