03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Gather<strong>in</strong>g Data from the User x 325<br />

7. For each of the five validation controls you added, open the Properties Grid <strong>and</strong> set the Text property<br />

to an asterisk (*), the Display property to Dynamic, <strong>and</strong> the CssClass to ErrorMessage. To<br />

do this for all controls at once, select the first validator control, then press the Ctrl key <strong>and</strong> click<br />

the others. When you make changes to the Properties Grid while you’ve selected multiple controls,<br />

the changes are applied to all of them.<br />

8. Next, set the rema<strong>in</strong><strong>in</strong>g properties for the controls as shown <strong>in</strong> the follow<strong>in</strong>g table.<br />

Control Properties You Need to Set Values You Need to Set<br />

RequiredFieldValidator (for<br />

the first e-mail address)<br />

ErrorMessage:<br />

ControlToValidate:<br />

Enter an e-mail address<br />

EmailAddress<br />

RegularExpressionValidator ErrorMessage: Enter a valid e-mail address<br />

RequiredFieldValidator (for<br />

the second e-mail address)<br />

ControlToValidate:<br />

ErrorMessage:<br />

ControlToValidate:<br />

EmailAddress<br />

Confirm the e-mail address<br />

ConfirmEmailAddress<br />

CompareValidator ErrorMessage: The e-mail addresses don’t<br />

match<br />

RequiredFieldValidator (for<br />

the Comments field)<br />

ControlToCompare:<br />

ControlToValidate:<br />

ErrorMessage:<br />

ControlToValidate:<br />

EmailAddress<br />

ConfirmEmailAddress<br />

Enter a comment<br />

Comments<br />

9. Still <strong>in</strong> Design View, click the<br />

RegularExpressionValidator once,<br />

open its Properties Grid, <strong>and</strong> locate the<br />

ValidationExpression property. When you click<br />

the property <strong>in</strong> the grid, the grid shows a button with<br />

an ellipsis. When you click that button, you get a<br />

dialog box that enables you to select a regular expression,<br />

shown <strong>in</strong> Figure 9-7.<br />

10. Scroll down <strong>in</strong> the list <strong>and</strong> then click Internet e-mail<br />

address from the list <strong>and</strong> note that VS <strong>in</strong>serts a long<br />

FIGURE 9-7

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

Saved successfully!

Ooh no, something went wrong!