4

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 :)

tereško
  • 57,247
  • 24
  • 95
  • 149
Bafla13
  • 132
  • 2
  • 11

1 Answers1

5

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.

Community
  • 1
  • 1
Yaakov Ellis
  • 39,558
  • 26
  • 126
  • 172