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 Parent Model from within the partial view. I need the Id of the parent.
Does a partial view automatically have access to the model of the parent?
Best Answer
You cannot access the parent model from a partial view unless you pass some value to this partial as parameters when rendering it. For example in your main view:
and then inside your partial you could access the
Id
:Of course this is a pretty lousy way of passing data to a partial view. The correct way is to use a strongly typed view model.