Chapter 9. Validating User Input
WHAT YOU WILL LEARN IN THIS CHAPTER:
What user input is and why it's important to validate it
What ASP.NET 4 has to offer to aid you in validating user input
How to work with the built-in validation controls and how to create solutions that are not supported out of the box
How to send e-mail using ASP.NET
How to read text files
So far you have been creating a fairly static web site where you control the layout and content by adding fixed pages to the site and its navigation menus. But you can make your site a lot more attractive by incorporating dynamic data. This data usually flows in two directions: it either comes from the server and is sent to the end user's browser, or the data is entered by the user and sent to the server to be processed or stored.
Data coming from the server can be retrieved from many different data sources, including files and databases, and is often presented with the ASP.NET data controls. You see how to access databases in Chapter 12 and onward.
The other flow of data comes from the user and is sent to the server. The scope of this information is quite broad, ranging from simple page requests and "Contact Us" forms to complex shopping cart scenarios and wizard-like user interfaces. The underlying principle of this data flow is basically the same in all scenarios — users enter data in a Web Form and then submit it to the server.
To prevent your system from receiving invalid data, it's important to validate this data before you allow ...