View에 여러 모델을 전달해야하며 View를 강력하게 입력하고 싶습니다. (도움을 줄 수 있으면 통과하지 않고이 작업을하고 싶습니다. ViewBag에 대한 내 모델 하나 하나).ASP.NET MVC 4 모델 캡슐화 렌더링보기 오류
Public Class TestModels
Public Class TestDetail
Public firstModel As firstModelHere ' An entity
Public secondModel As secondModelHere ' An entity
Sub New()
firstModel = Nothing
secondModel = Nothing
End Sub
End Class
End Class
모델에 대한 디렉토리의 독립된 파일에 있습니다. 나는 그렇게처럼 내보기로 캡슐화 된 모델을 통과 :
@ModelType Website.TestModels.TestDetail
@Html.LabelFor(Function(model) model.firstModel.userName)
@Html.LabelFor(Function(model) model.secondModel.lastName)
그리고 나는 내 컨트롤러에 firstModel 및 secondModel를 설정하고 볼 수있는 모델을 전달합니다. 프로젝트를 컴파일 할 때 수십 개의 오류가 발생합니다 (아래 참조). 어떻게 해결할 수 있습니까? 나는 단순히 내 Views에서 다른 클래스에 캡슐화 된 여러 모델에 액세스 할 수 있기를 원합니다. 미리 감사드립니다. 내가 코딩 트릭이나 패턴을 잃었 경우
Error 134 'ViewBag' is not declared. It may be inaccessible due to its protection level.
Error 129 'Context' is not declared. It may be inaccessible due to its protection level.
Error 138 'Layout' is not declared. It may be inaccessible due to its protection level.
Error 131 sub 'Execute' cannot be declared 'Overrides' because it does not override a sub in a base class.
...