Search code examples
jqueryjsonasp.net-mvcpartial-viewsdatatemplate

Is JSON better than Partial Views for all use cases in ASP.NET MVC?


There is a utility in jQuery called data template that can render the data through a template system.

Are data templates better than RenderPartial?

Can somebody explain their experience with it.

In my scenario it would be better because they make one less step for the developer and it is very customizable because it's easy to edit the template in the JS code instead of going to create new partial views.

So what is the better option in ASP.NET MVC?


Solution

  • I am making the assumption you are working with MVC and are referring to partial views.

    Partial view render on the server in one pass and are part of the page structure. Ajax calls will download the page first then inject the additional content later.

    Partial view give you SEO indexing. Ajax call give you intial page load speed.

    Typically you want as much as possible in your initial page load then add dynamic content/feedback elements via ajax to enhance the user experience.