Html 同一页面中的多个视图 MVC ASP.NET
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15477676/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Multiple Views in the same page MVC ASP.NET
提问by Mangesh Kaslikar
I want to display different Viewson the same page in ASP.NET MVC technology . How can it be acheived.
我想在 ASP.NET MVC 技术的同一页面上显示不同的视图。怎么可能达到。
I have data coming in from 2 different Tables and for that i have 2 different Viewsfor display. How can I display both these views on one single page.
我有来自 2 个不同表的数据,为此我有 2 个不同的视图用于显示。如何在一个页面上显示这两个视图。
Is there a concept of a Viewwithin a view in MVC ? Or is there some provision for making a master view which can encapsualte multiple views. ?
MVC 中的视图中是否有视图的概念?或者是否有一些规定可以制作可以封装多个视图的主视图。?
采纳答案by Satpal
These link's will help you (first gain knowledge of Partial view)
这些链接将帮助您(首先了解部分视图)
回答by Kapil Khandelwal
ASP.NET MVC supports the ability to define "partial view"templates that can be used to encapsulate view rendering logic for a sub-portion of a page. "Partials" provide a useful way to define view rendering logic once, and then re-use it in multiple places across an application.
ASP.NET MVC 支持定义“部分视图”模板的能力,这些模板可用于封装页面子部分的视图呈现逻辑。“部分”提供了一种有用的方法来定义视图呈现逻辑一次,然后在应用程序的多个位置重复使用它。
Refer:
参考:
回答by Tom Stickel
Yes, the aspx webforms has the Master page and then you use user controls .ascx files.
是的,aspx webforms 有母版页,然后你使用用户控件 .ascx 文件。
With MVC, the "master page" is by default under
使用 MVC,“母版页”默认位于
Views\Shared\_Layout.cshtml
Now you can also end up using the wonderful Twitter bootstrap and really start to make greater looking layouts with easy to use css etc..
现在你也可以最终使用精彩的 Twitter 引导程序,并真正开始使用易于使用的 css 等来制作更美观的布局。
Your controller can return
您的控制器可以返回
PartialViewResult
as mentioned by the other answers from the others, those links should get you on your way.
正如其他人的其他答案所提到的那样,这些链接应该会让您继续前进。