html.partial vs html.renderpartial and Html.Action vs Html.RenderAction

Jacob
Jacob
Member
56 Points
13 Posts

Hi,

What is difference between html.partial and html.renderpartial? And also want to know about  Html.Action and Html.RenderAction.

Views: 9466
Total Answered: 1
Total Marked As Answer: 0
Posted On: 25-Nov-2015 10:31

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Teacher
4822 Points
23 Posts
         

Hi Jacob,

Html.Partial and Html.RenderPartial:

Both uses to rendering partial view and no need to create action.

Difference:

  • Html.Partial renders partial view as an HTML-encoded string while Html.RenderPartial method result directly written to to the HTTP response stream that is it used the same TextWriter object as used in the current webpage/template
  • Html.Partial method's result can be stored in a variable, since it returns string type value while Html.RenderPartial method returns void.
  • Html.RenderPartial is faster than Html.Partial.

Uses:

  • Html.RenderPartial and Html.Partial methods are useful when the displaying data in the partial view is already in the corresponding view model

Html.Action and Html.RenderAction:

Both uses to rendering partial view and need to create action.

Difference:

  • Html.Action renders partial view as an HTML-encoded string while Html.RenderAction method result directly written to to the HTTP response stream that is it used the same TextWriter object as used in the current webpage/template
  • Html.Action method's result can be stored in a variable, since it returns string type value while Html.RenderAction method returns void.
  • Html.RenderAction is faster than Html.Action.

Uses:

  • Html.RenderAction and Html.Action methods are useful when the displaying data in the partial view is independent from corresponding view model.
  • These methods are also the best choice when you want to cache a partial view.
Posted On: 26-Nov-2015 22:43
 Log In to Chat