asp.net-mvcPartial Views


Introduction

A partial view is a view that is rendered within another view. Partial views can be reused and thus prevent duplication of code. They can be rendered by Html.Partial or Html.RenderPartial

Syntax

  • @Html.Partial("ViewName")

    @Html.Partial("ViewName",ViewModel)

    @{Html.RenderPartial("ViewName");}

    If your partial view is located in a different folder other than shared folder, then you will have to mention full path of the view as below:

    -@Html.RenderPartial("~/Areas/Admin/Views/Shared/partial/_subcat.cshtml")