RenderPartial writes the result directly to the response, technically speaking, directly into the calling object's TextWriter.
Partial on the other hand returns the HTML markup as string, which buffers the content. It achieves by creating and using a separate TextWriter.
Syntactic representation:
RenderPartial should be used inside a code block (obviously followed by a semicolon).
Partial can be used directly as it returns the HTML markup as string.
Usage:
Considering the performance RenderPartial is a bit faster and hence developers prefer using it inside the looping constructs and related scenarios.
Preference of Partial prevails in the case of regular syntax usage(meaning - uniform syntax usage as we don't need to wrap inside the code block) and if we need to perform any manipulation with the resultant HTML markup string.
Partial on the other hand returns the HTML markup as string, which buffers the content. It achieves by creating and using a separate TextWriter.
Syntactic representation:
RenderPartial should be used inside a code block (obviously followed by a semicolon).
@{ Html.RenderPartial("TestPartialView1"); }
Partial can be used directly as it returns the HTML markup as string.
@Html.Partial("TestPartialView1")
Usage:
Considering the performance RenderPartial is a bit faster and hence developers prefer using it inside the looping constructs and related scenarios.
Preference of Partial prevails in the case of regular syntax usage(meaning - uniform syntax usage as we don't need to wrap inside the code block) and if we need to perform any manipulation with the resultant HTML markup string.
No comments:
Post a Comment