2
我需要传递多个模型到一个视图,我希望视图是强类型的(所以如果我可以帮助它,我想这样做而不使用传递我的模型中的每一个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.
...