03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9Validat<strong>in</strong>g<br />

User Input<br />

WHAT YOU WILL LEARN IN THIS CHAPTER:<br />

‰ What user <strong>in</strong>put is <strong>and</strong> why it’s important to validate it<br />

‰ What <strong>ASP</strong>.<strong>NET</strong> <strong>4.5</strong> has to offer to aid you <strong>in</strong> validat<strong>in</strong>g user <strong>in</strong>put<br />

‰ How to work with the built-<strong>in</strong> validation controls <strong>and</strong> how to create<br />

solutions that are not supported out of the box<br />

‰ How to send e-mail us<strong>in</strong>g <strong>ASP</strong>.<strong>NET</strong><br />

‰ How to read text files<br />

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER<br />

You can f<strong>in</strong>d the wrox.com code downloads for this chapter on the Download Code tab at<br />

www.wrox.com/remtitle.cgi?isbn=1118311809. The code is <strong>in</strong> the Chapter 9 download.<br />

So far you have been creat<strong>in</strong>g a fairly static website where you control the layout <strong>and</strong> content<br />

by add<strong>in</strong>g fixed pages to the site <strong>and</strong> its navigation menus. But you can make your site a lot<br />

more attractive by <strong>in</strong>corporat<strong>in</strong>g dynamic data. This data usually flows <strong>in</strong> two directions: it<br />

either comes from the server <strong>and</strong> is sent to the end user’s browser, or the data is entered by the<br />

user <strong>and</strong> sent to the server to be processed or stored.<br />

Data com<strong>in</strong>g from the server can be retrieved from many different data sources, <strong>in</strong>clud<strong>in</strong>g files<br />

<strong>and</strong> databases, <strong>and</strong> is often presented with the <strong>ASP</strong>.<strong>NET</strong> data controls. You see how to access<br />

databases <strong>in</strong> Chapter 12 <strong>and</strong> onward.<br />

The other flow of data comes from the user <strong>and</strong> is sent to the server. The scope of this <strong>in</strong>formation<br />

is quite broad, rang<strong>in</strong>g from simple page requests <strong>and</strong> “Contact Us” forms to complex<br />

shopp<strong>in</strong>g cart scenarios <strong>and</strong> wizard-like user <strong>in</strong>terfaces, but the underly<strong>in</strong>g pr<strong>in</strong>ciple of this<br />

data flow is basically the same <strong>in</strong> all scenarios—users enter data <strong>in</strong> a Web Form <strong>and</strong> then submit<br />

it to the server.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!