In MVC do partial views inherit the models of their Parent views?

后端 未结 2 1400
长发绾君心
长发绾君心 2021-01-19 00:45

I\'m passing some data to a View from my controller, which I wish to display inside a partial view inside that View (don\'t ask, it\'s complicated). I know I probably should

2条回答
  •  日久生厌
    2021-01-19 01:32

    You can pass the model into the partial view as a second parameter using the overload:

    @Html.Partial("viewname", Model)
    

    Nothing wrong with this approach IMO as its the whole point in strongly-typed views and the benefits they bring...

提交回复
热议问题