What is Difference between Html.Partial and Html.RenderPartial in MVC? [Resolved]

Posted by Kumarkrishna184 under ASP.NET MVC on 4/5/2016 | Points: 10 | Views : 413 | Status : [Member] | Replies : 1
What is Difference between Html.Partial and Html.RenderPartial in MVC?

I know that Html.Partial() returns string and Html.RenderPartial() return void. But internally how it perform......?Please explain

Thanks and Regards,
Krishna Kumar



Responses

Posted by: Rajnilari2015 on: 4/5/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Html.Partial
--------------

It renders the partial view as an HTML-encoded string and returns MvcHtmlString. Since it returns string value(s),it can be assigned to a variable and manipulate if needed. e.g
@Html.Partial("SomeViewName")


Html.RenderPartial
-------------------

When we have a model to send to the view and there will be a lot of html that doesn't need to be stored in a variable.The result will be written to the Response stream during execution.e.g
@{ Html.RenderPartial("SomeViewName");}


For more info, please refer the Techfunda article : http://techfunda.com/howto/604/nested-partial-view

--
Thanks & Regards,
RNA Team

Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response