Home > DeveloperSection > Forums > What is the difference between Html.Partial and Html.RenderPartial and Html.Action and Html.RenderAction?
Mark Devid
Mark Devid

Total Post:102

Points:714
Posted on    October-06-2014 11:58 PM

 ASP.NET MVC ASP.Net  ASP.NET MVC 
Ratings:


 1 Reply(s)
 945  View(s)
Rate this:

In ASP.NET MVC, what is the difference between:

·         Html.Partial and Html.RenderPartial

·         Html.Action and Html.RenderAction

 



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    October-07-2014 12:03 AM

Html.Partial returns a String, Html.RenderPartial calls write internally, and returns void.

The basic usage is.

@Html.Partial("ViewName")

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

 

@{

    Html.Partial("ViewName");

    Html.RenderPartial("ViewName");

}

In the snippet above, both calls will yield the same result.

While one can store the output of Html.Partial in a variable or return it from a method, one cannot do this with Html.RenderPartial . The result will be written to the Response stream during execution/evaluation.

This also applies to Html.Action and Html.RenderAction.


Don't want to miss updates? Please click the below button!

Follow MindStick