Mangesh Kaslikar
Mangesh Kaslikar

Reputation: 591

Multiple Views in the same page MVC ASP.NET

I want to display different Views on the same page in ASP.NET MVC technology . How can it be acheived.

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.

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. ?

Upvotes: 8

Views: 38573

Answers (3)

Tom Stickel
Tom Stickel

Reputation: 20401

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

With MVC, the "master page" is by default under

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..

Your controller can return

PartialViewResult

as mentioned by the other answers from the others, those links should get you on your way.

Upvotes: 1

Kapil Khandelwal
Kapil Khandelwal

Reputation: 16144

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.

Refer:

Re-use UI Using Master Pages and Partials

Creating Partial View

Upvotes: 2

Related Questions