Difference between Html.RenderPartial and Html.Render

3.3k Views Asked by At

I am new to asp.net and im have a page that i want to show as a partial view. The page is in a div tag ,like this <div> Html.RenderPartial("view",Model)</div> and im doing the same thing with Html.Render but it works just with RenderPartial.

Does anyone have any idea why,and what es the difference?? i know that Renderpartial ist better for Image and etc.. but is there another difference??? Thx very much :)

1

There are 1 best solutions below

0
Yaakov Ellis On

This answer should give you what you are looking for (copying relevant sections):

Html.Partial returns a string, Html.RenderPartial calls Write internally, and returns void. The usage (using Razor syntax):

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

Will do exactly the same. You can store the output of Html.Partial in a variable, or return it from a function. You cannot do this with Html.RenderPartial. The result will be written to the Response stream during the execution.