면도기 뷰가 여러 모델을 처리하는 가장 좋은 방법은 무엇입니까? MVC3 응용 프로그램 용.면도기 뷰의 다중 뷰 모델
나는 두 가지 모델이 모두 유사하지만, 우편 번호 필드가 아니라 내가 전달하고 국가에 따라 특정 뷰 모델을 사용하려면 컨트롤러에서 다른
public class IrelandPostcodeLookupViewModel , IWithProgress
{
readonly Progress _Progress = new Progress(Step.Delivery);
public Progress Progress
{
get { return _Progress; }
}
[Required(ErrorMessage = "Please enter your house number or name")]
[DisplayName("House number or name")]
public string HouseNumber { get; set; }
[StringLengthWithGenericMessage(50)]
[DisplayName("Eircode")]
public string Postcode { get; set; }
}
public class PostcodeLookupViewModel , IWithProgress
{
readonly Progress _Progress = new Progress(Step.Delivery);
public Progress Progress
{
get { return _Progress; }
}
[Required(ErrorMessage = "Please enter your house number or name")]
[DisplayName("House number or name")]
public string HouseNumber { get; set; }
[StringLengthWithGenericMessage(50)]
[Required(ErrorMessage = "Please enter your postcode")]
[DisplayName("PostCode")]
public string Postcode { get; set; }
}
에 대한 하나 개의 모델이 필요합니다 . '
@model dynamic
나는이 함께이 문제를
public virtual ActionResult PostcodeLookup(string country)
{
if (country == Country.UnitedKingdom)
return View(new PostcodeLookupViewModel());
else
return View(new IrelandPostcodeLookupViewModel());
}
내가보기에이 문제를 처리하는 것처럼 뭔가 내보기 부분 뷰
@Html.Partial("~/Views/Shared/_Progress.cshtml", Model.Progress)
이 들어 내가 오류로 실행 HtmlHelper '에는'Partial '이라는 적용 가능한 메소드가 없지만 해당 이름으로 확장 메소드가있는 것 같습니다. 확장 메서드를 동적으로 디스패치 할 수 없습니다. '
내가 어떻게 부분 뷰를 처리 할 수있는 조언을 할 수 있습니까? Model
이 dynamic
입니다
감사