Reputation: 377
I want views several partial view into a one view. In fact, it is like a master form that also includes several sub-forms. How do I do this?
Upvotes: 2
Views: 3956
Reputation: 1038720
You could put this in a partial:
@Html.Partial("Partial1")
@Html.Partial("~/Views/Foo/Partial2")
@Html.Partial("Partial3")
and finally include this partial somewhere:
@Html.Partial("CombinedViewsPartial")
Upvotes: 4
Reputation: 52518
In your view, use this:
@Html.Partial("NameOfYourView")
@Html.Partial("../OtherViewFolder/NameOfPartialView", varToPassAsModel)
Or in a loop:
@foreach(var orderLine in model.OrderLines) {
@Html.Partial("../OrderLine/Details", orderLine) @* Without executing another controller *@
@Html.Action("Details", "OrderLine", new { lineNr = orderLine.LineNr, orderNr = orderLine.OrderNr }) @* Goes through controller *@
}
Upvotes: 2