Skip to Content
Beginning ASP.NET MVC 1.0
book

Beginning ASP.NET MVC 1.0

by Simone Chiaretta, Keyvan Nayyeri
August 2009
Beginner to intermediate content levelBeginner to intermediate
575 pages
13h 16m
English
Wrox
Content preview from Beginning ASP.NET MVC 1.0

Chapter 6. The View

The view is the part of a Model-View-Controller application that interacts with the end-users and that lays out the data retrieved by the controller on an HTML page. Even though its purpose is just writing some HTML code, if done wrong, a view can turn the application into a maintenance nightmare.

In this chapter you learn:

  • How to create a view

  • What the responsibilities of the view are

  • How to write HTML forms

  • How to extend a view

The Responsibilities of the View

In the previous chapter you probably noticed that the MVC mantra about having a skinny controller and a fat model also includes an adjective for the view: dumb. This means that the view must not have business logic, but should only take the data it receives from the controller and insert it into the page's HTML. The only logic allowed inside the view is some conditional formatting or hiding/showing areas of the page based on certain conditions, but that should be all.

You already read this guideline in the previous chapter. We're stressing it here because it is a very important concept, which if not applied can make the use of MVC useless. But enough with theoretical concepts: The rest of the chapter is all about how to create a view and write HTML in it.

The Anatomy of a View

You already created some views in the examples in previous chapters, so you might already have guessed what the rules for creating a view might be. Now it's time to lay them down in detail.

Before diving deeply into the view, there is a part ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning ASP.NET MVC 4

Beginning ASP.NET MVC 4

José Rolando Guay Paz
Programming ASP.NET MVC 4

Programming ASP.NET MVC 4

Jess Chadwick, Todd Snyder, Hrusikesh Panda
Professional ASP.NET MVC 2

Professional ASP.NET MVC 2

Jon Galloway, Phil Haack, Scott Hanselman, Scott Guthrie, Rob Conery

Publisher Resources

ISBN: 9780470433997Purchase book