Search code examples
asp.net-mvchtml-helperasp.net-mvc-partialview

HtmlHelper extension method vs partial view?


I curious when it's recommended to use HtmlHelper extension method and when to use partial view? They seem to be equally eligible in many cases.


Solution

  • I personally think that partial view is more or less similar to usercontrol in asp.net, which act as a group of reusable functional elements. For example, if you need to make a login control box that may appear across the whole site, partial view would be better. What's more for partial view is, it is actually self-contained with its own rendering/processing strategy (and may have its own state as well)

    On the other hand, htmlhelper is just tools for saving coding time and maintain, somehow better readability on your codes.