Access Parent Model from partial view

前端 未结 5 2012
半阙折子戏
半阙折子戏 2021-01-07 22:00

I\'m asking because the partial view I will create is blank, with the purpose of creating a new child entity. I just need a quick, regardless if dirty, way to access the Pa

5条回答
  •  执笔经年
    2021-01-07 22:36

    You can just pass the model IE:

    The encapsulating view:

        @model MyModel
        @Html.Partial("_myPartial", Model)
    

    Partial View:

        @model MyModel
        Id = @Model.Id;
    

提交回复
热议问题