Tuesday, May 3, 2022

WHAT ARE PARTIAL VIEWS IN ASP.NET MVC

 Partial View is a subpage of Main View page that keeps reusable parts of web pages. If your Main Page is too large then you can divide it into several pieces and store content into a partial page with a logical name. After that, you can call this partial page inside your main view page.


More Facts about Partial Page:

1. It is an effective way to breaking up large view pages into smaller components.

2. A partial page is reusable so keep common content in the partial page and used wherever you want.

3. You can recall partial page inside a view page using following ways:


@Html.Partial("ViewName")

// A view with this name must be in the same folder
@Html.Partial("ViewName.cshtml")

// Locate the view based on the application root
// Paths that start with ".php" or "~.php" refer to the application root
@Html.Partial("~/Views/Folder/ViewName.cshtml")
@Html.Partial("/Views/Folder/ViewName.cshtml")

// Locate the view using relative paths
@Html.Partial("../Account/LoginPartial.cshtml")
Use below link for more info
https://www.completecsharptutorial.com/asp-net-mvc5/adding-partial-views-pages-in-mvc-5-with-example.php

No comments:

Post a Comment