please give me brief explanation about view and partial view.
Define view and partial view?
36622-Jan-2020
Updated on 22-Jan-2020
Home / DeveloperSection / Forums / Define view and partial view?
please give me brief explanation about view and partial view.
Nishi Tiwari
23-Jan-2020View
View contains the layout page.
_viewstart page is rendered before any view is rendered. We cannot place any common code for a partial view within the _viewStart.cshtml page.
View may have markup tags like html, body, head, title, meta etc.
If there is no layout page specified in the view, it can be considered as a partial view. In razor, there is no distinction between views and partial views as in the ASPX view engine (aspx and ascx).
A view is mainly responsible for the UI (user interface).
The view displays the data which is coming from the model.
A view is the HTML template that will be binding and displaying HTML controls with data.
The “.cshtml” file use the Razor view engine. And .cshtml view use C# programming.
A view may contain “HTML” and “C#” code. It is a combination of C# and Html (.cshtml)
The return type of view are “ViewResult” or “ActionResult”.
Partial View
Partial view does not contain the layout page.
Partial view does not check for a _viewstart.cshtml.
The Partial view is specially designed to render within the view and as a result it does not contain any mark up.
Partial view is more lightweight than the view. We can also pass a regular view to the RenderPartial method.
Partial view in ASP.NET MVC is defined as a special view which renders a portion of view content only. It is just like an user control of the web form application. Partial may be reusable in multiple views. It also helps us to reduce code duplication. In other word we can say a partial view enables us to render a view within the parent view.