Types of views in MVC

Ratings:
(4.2)
Views: 1986
Banner-Img
Share this blog:

Types of views in MVC - ASP.Net

There are 3 types of view available in MVC

  1. View page
  2. Master page view
  3. Partial view
  1. View page:

In general, this is inherited from the view page class to create a normal page within MVC, we use this view

2In general, to create this view we use the view page template, i.e., MVC to view page template in MVC application.

2The inherited class name will be available in <%@ page directive with inherits attributes.

2To create a view page that contains a master page we use a template known as “MVC2 view content page”.

  1. Master page view:

2This is used to create a master page within the MVC application.

2To create a master page view we use a template known as “MVC2 view master page.”

2This is going to inherit a clan i.e., “system.web.MVC.view master page” it is possible to create the master page dynamically in MVC just like in ASP.net

The master page view will have a default extension of. master

Learn ASP.Net by Tekslate - Fastest growing sector in the industry. Explore Online "ASP.Net Training" and course is aligned with industry needs & developed by industry veterans. Tekslate will turn you into ASP.Net Expert.
  1. Partial views:

2Partial views are similar to the user controller in ASP.net

2This will have a default extension of. ascx similar to ASP.net user controller

2This is inherited from the class “system.web.mvc.view user control”.

2In general, this can be included in any other view page just like in ASP.net user controllers.

Creating a view page:

Go to solution explorer

3

Select the home folder from views

3

Click with RM button

3

Click on add

3

Click on a new item

3

Select MVC2 view page template

3

Type the view name (sample.asp x)

3

Click on add

2Go to the source part of the page

Type following in body part

<H2> welcome to satya technologies</H2>

2Go to controls folder

3

Double click on home controller .cs

3

Add new action method with the name (sample)

Like

Public action result sample ()

{

Return view ();

}

To run this page directly

3

Go to register routes method

3

Change the action name from index to sample

  • Creating a master view page:

Go to solution explorer

3

Select a shared folder from views folder

3

Click with RM button

3

Click on add

3

Click on a new item

3

Select MVC2 view master page template

3

Type the master page name (abc.master)

3

Click on add

3

Go to source part --> write the following code

<Body>

<h1 align=’center’>satya technologies </h1>

</body>

Creating a content page:

Select the home folder from views

3

Click with RM button

3

Click on add

3

Click on a new item

3

Select MVC2 view content page template

3

Type the content page name (cp1.aspx)

3

Click on add

3

A select master page dialogue box is displayed

3

Select the abc.masteràclick on ok

3

To run this page use the following steps

3

Go to the home controller .cs file

3

Write the code for action result

2Public action result cp1 ()

{

Return view ();

}

Then go to global.asax file

3

Change the action name to cp1.

3

Run the application and check

For in-depth understanding click on

 

You liked the article?

Like: 0

Vote for difficulty

Current difficulty (Avg): Medium

EasyMediumHardDifficultExpert
IMPROVE ARTICLEReport Issue

About Author

Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox