What Is A View?
A view is one of the three primary components of the Model-View-Controller pattern. In the context of ASP.NET MVC, the view is the primary mechanism for defining the Html sent back to the browser on the page request. It is the view that most corresponds to the idea of a page, but the terms are not quite synonymous.
As a good first step to understanding views, read the "Creating a View" tutorial in the "Getting Started" section.
So what makes up a view? Often it will end up being a plain ol' Html file with the normal Html elements in it. If the view is using a MasterPage then it will have its Html grouped in the normal Content controls that come with using MasterPages. If the view hosts an Html form, it will likely contain a number of calls to the built-in HtmlHelper class to aid in rendering the input elements.
This is what a view looks like when I create it for this project:
Because of my MasterPage there is an extra Content tag ("Sidebar"), but other than that nothing else is particularly project-specific.
Outside of the material in the "Creating a View" tutorial there are what I consider two other basic topics in view creation, getting data to a view using ViewData and the building strongly-typed views.
Speak Your Mind!
Have something to say? Find a grammatical mistake? Think I said something incorrect? Don't like my perspective? Hate my color scheme? Whatever it is, you can let me know. I would appreciate it if you did.
