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?
2 Answers
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 *@
}
1 Comment
Amir978
Hi Maryam, Please select the answer that helped you to solve your problem or at least explain how your problem was solved. By doing this you respect the person who helped you and also you help the other website users to learn more from your experience. Thanks