I have two partial views which are exactly the same, but for the @model.
@model Project.Models.X
@model Project.Models.Y
How could I pass this model type to the view so that I can use the same view for both?
Not sure if this is best practice, but you could also use HTML.RenderAction to call your controller and have it return a PartialViewResult with whatever model you want, like so:
@{Html.RenderAction("MyPartialAction", "MyController", new { someID = 1 });}
and
public PartialViewResult MyPartialAction(int? someID)
{
return PartialView("MyPartial",SomeModel);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With