10
Using the Controller I can return a Partial View, JSON, string and other things.
What is a Partial View? Is it widely used in projects? Why use it?
10
Using the Controller I can return a Partial View, JSON, string and other things.
What is a Partial View? Is it widely used in projects? Why use it?
13
It’s a part of view, a part of the HTML code that will be generated. It works as if it were a control that would be inserted into HTML with its own characteristics (today it has better mechanisms for this, but it does not mean that it should not be used more).
It is common to have complex pages where it would be difficult to assemble everything as if it were one thing. We adopted the technique of divide and conquer. Each of these partial views takes care of a part of the content that will be rendered, forming the view all.
But this has another huge advantage, upgrades can be made more granular. When only part of the information is updated, you do not need to regenerate the whole view - obviously if the page is written in a way that guarantees this, probably via AJAX.
Another obvious advantage is that it can be consumed by several views different.
You may have controllers/actions connected directly to these views partial or use them in controllers/actions that will generate other views. There’s syntax for this. Of course they can consume their own models.
They do not have layout, only the content matters.
Unless you’re creating pages old-fashioned and very simple, it will certainly be very useful. So it can be said that it is used in virtually every project that proposes to use MVC.
Browser other questions tagged c# asp.net-mvc .net asp.net-mvc-5 view
You are not signed in. Login or sign up in order to post.
Thank you very much, I created one here to test !
– Lucas Vasconcelos Busto
A dropdown that displays information from a state that is in a View(View Model is the Person entity) that registers a person should be a Partial View?
– Marconi