O'Reilly logo

Programming ASP.NET MVC 4 by Hrusikesh Panda, Jess Chadwick, Todd Snyder

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Working with Data

It’s rare to find an application that doesn’t deal with data in some way, so it’s probably no surprise that ASP.NET MVC provides excellent support at all levels of the framework to make working with data much easier. In this chapter, we’ll take a look at the tools that provide that support and show you how to leverage them in your data-driven scenarios by adding this functionality to the EBuy reference application.

Since EBuy is an auction site, the site’s most important scenario is allowing users to create auction listings that contain the details of the items they would like to sell. So, let’s take a look at how ASP.NET MVC can help us support this important scenario.

Building a Form

The concept of an HTML form is as old as the Web itself. Though browsers have gotten more advanced, to the point that you can style an HTML form to look just about any way you like and apply JavaScript to make it behave in ways you wouldn’t have believed possible five years ago, underneath it all is still just a bunch of plain old form fields ready to be populated and posted back to the server.

While ASP.NET MVC encourages you to author much of your HTML markup “by hand,” the framework offers an array of HTML helpers to help generate HTML form markup, such as Html.TextBox, Html.Password, and Html.HiddenField, just to name a few. ASP.NET MVC also offers a few “smarter” helpers, such as Html.LabelFor and Html.EditorFor, that dynamically determine the appropriate HTML based on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required