同一页面中的多个视图MVC ASP.NET

时间:2021-07-08 16:49:42

I want to display different Views on 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 Views for display. How can I display both these views on one single page.

我有来自2个不同表的数据,为此我有2个不同的视图用于显示。如何在一个页面上显示这两个视图。

Is there a concept of a View within a view in MVC ? Or is there some provision for making a master view which can encapsualte multiple views. ?

在MVC的视图中是否有View的概念?或者是否有一些用于制作可以封装多个视图的主视图的规定。 ?

3 个解决方案

#2


1  

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支持定义“部分视图”模板的功能,这些模板可用于封装页面子部分的视图呈现逻辑。 “Partials”提供了一种定义视图呈现逻辑的有用方法,然后在应用程序的多个位置重用它。

Refer:

Re-use UI Using Master Pages and Partials

使用母版页和部分重复使用UI

Creating Partial View

创建局部视图

#3


1  

Yes, the aspx webforms has the Master page and then you use user controls .ascx files.

是的,aspx webforms具有Master页面,然后您使用用户控件.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.

正如其他人的其他答案所提到的那样,这些链接应该让你顺利。

#1


#2


1  

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支持定义“部分视图”模板的功能,这些模板可用于封装页面子部分的视图呈现逻辑。 “Partials”提供了一种定义视图呈现逻辑的有用方法,然后在应用程序的多个位置重用它。

Refer:

Re-use UI Using Master Pages and Partials

使用母版页和部分重复使用UI

Creating Partial View

创建局部视图

#3


1  

Yes, the aspx webforms has the Master page and then you use user controls .ascx files.

是的,aspx webforms具有Master页面,然后您使用用户控件.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.

正如其他人的其他答案所提到的那样,这些链接应该让你顺利。