Difference between Partial View and Render Partial View

Difference between Partial View and Render Partial View

In MVC there are two ways of calling your partial view:

  • Partial View
  • Render Partial View

Partial View

  • Return Type: Partial View returns the MvcHtmlString which can be assigned to a variable and manipulate it if required.

    Below Image shows the MVCHTMLString return type of partial view.

    Partial View

  • When to use: Whenever output of the partial view needs to be assigned to variable and manipulate with it then use partial view.

  • Performance: This type of view is slower in performance.

    Syntax:


    @Html.Partial("_PartialStudent", Model)

Render Partial View

  • Return Type: Render Partial View returns void and output will be written directly to the output stream.

    Below Image shows the Void return type of render partial view.

    Render

  • When to use: Whenever output of partial view needs to display as it is then use Render Partial view.

  • Performance: This type of view is faster in performance.

  • Syntax:

    @{Html.RenderPartial("_PartialStudent", Model); }
Ebook Download
View all
Learn
View all