In web form we use create and use reusable component e.g web user control or a web server control. Similarly in MVC we will use Partial view.

Partial views can be placed in Views folder and each view folder for Controller as shown below.

ASP.NET MVC Partial View

Characteristics of is Partial view:

It’s a view who do not have layout defined,  starts with '_' , can be placed in shared views folder.

Where / When to Partial views can be used?

  • Need to reuse same view at multiple places (e.g. Header, Footer, Left panel)
  • Need to use multiple / Related models in Main view (e.g. Get Products additional Info )

Syntax of using Partial view :

Html.RenderPartial("~/Views/Shared/_Header.cshtml");

Html.RenderPartial("~/Views/Shared/_Product.cshtml", product);

OR

@Html.Partial("~/Views/Shared/_Header.cshtml");

@Html.Partial("~/Views/Shared/_Product.cshtml", product);