Home/MVC/MVC Razor : Difference between @Html.Partial() and Html.RenderPartial()

MVC Razor : Difference between @Html.Partial() and Html.RenderPartial()

Difference between @Html.Partial() and Html.RenderPartial()

  • Html.Partial returns a string, Html.RenderPartial returns void.
  • We can store the output of Html.Partial in a variable/able to return from function.
  • In Html.RenderPartial, we can’t result void.(ie.,directly writing to the output stream so it was bit faster than html.partial())

Example :

Renderpartial

If want to refere partial view inside the shared, then it will

READ  Partial View in MVC

@{ Html.RenderPartial(“_testPartial”);}

If want to refere partial view inside the view, then it will be

@Html.Partial(“../Home/testContentPartial”)

 

One Comment

  1. anonymous April 26, 2013 at 1:07 am

    Thank you for keeping us updated. I incredibly enjoy it and discover all the info very useful.

Leave A Comment