ProgrammerGuide.Net | Step by Step Programmer Guide

Difference Between Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction | ASP.NET MVC Tutorial

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

@{ Html.RenderPartial("ViewName");  }
The usage (using WebForms 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.
The same is true for Html.Action and Html.RenderAction.
Internally @Html.Partial calls RenderPartialInternal which is called by @Html.RenderPartial. The difference is that @Html.Partial returns the string created by RenderPartialInteral whereas @Html.RenderPartial does not return the string.
@Html.RenderPartial() has faster execution than @Html.Partial() due to Html.RenderPartial gives a quick response to Output.
When Html.RenderPartial() is called with just the name of the partial view, ASP.NET MVC will pass to the partial view the same Model and ViewData dictionary objects used by the calling view template.
The return type of Html.RenderAction is void that means it directly render the responses in View where return type of Html.Action is MvcHtmlString you can catch its render view in controller and modify it
Please click here for related products on Amazon!


Add comment

Want to Check Celebrities News?