Reputation: 874
I'm currently working on an ASP.Net MVC project and i'm using razor views. I've a controller's action; say action A which has its own razor view; say view A.
Also, i have another controller's action; action B, and has its own razor view; view B.
Now, i want to have the razor view A inside the razor view B; instead of copying all the view A contents in view B to avoid repeated code.
What do you suggest?
any idea would be appreciated.
Upvotes: 0
Views: 127
Reputation: 6000
if there is no model to pass then Inside B.cshtml
call (do not need .cshtml)
@Html.Partial("A")
with model
@Html.Partial("A", @Model.SubModel)
Upvotes: 1