• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Types of views in MVC

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 view page class to create a normal page with in MVC we use this view

2In general to create this view we use 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 master page we use a template known as “MVC2 view content page”

 

  1. Master page view:

2This is used 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

Master page view will have a default extension of .master

 

  1. Partial views:

2Partial views are similar to 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 including in any other view page just like in ASP.net user controllers.

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.

Creating a view page:

Go to solution explorer

3

Select home folder from views

3

Click with RM button

3

Click on add

3

Click on new item

3

Select MVC2 view page template

3

Type the view name (sample.asp x)

3

Click on add

 

2Go to 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 shared folder from views folder

3

Click with RM button

3

Click on add

3

Click on 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 home folder from views

3

Click with RM button

3

Click on add

3

Click on new item

3

Select MVC2 view content page template

3

Type the content page name (cp1.aspx)

3

Click on add

3

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 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 indepth understanding click on

Summary
Review Date
Reviewed Item
Types of views in MVC
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Types of views in MVC"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.