110 likes | 232 Views
Lesson 12. Adding Validation To The Movie Database. Show All Data. Create a new ASP.Net File and call it ShowAllData Go to data and drag the JamesBondSeries Table to the workspace Save the File Press F5 to view and then close. Adding A Hyperlink To Your Page.
E N D
Lesson 12 Adding Validation To The Movie Database
Show All Data • Create a new ASP.Net File and call it ShowAllData • Go to data and drag the JamesBondSeries Table to the workspace • Save the File • Press F5 to view and then close
Adding A Hyperlink To Your Page • File Open the AddRecord.aspx file • Drag a Hyperlink and place it to the right of the Button • In the Hyperlink Properties, go to Navigate Url and type ShowAllData.aspx • Go to Text and type View Data • Press F5 to view and click on View Data
Adding color to your page • Go to HTML view • Copy this code to add a background color and give your text color: • <body> • <body text="#ffffff" bgcolor="#000000"> • Press F5 to view
Validating Your Data • Web Matrix has some great features to make sure that users are going to enter the correct data into your database • These are called Validator Controls • There are several to choose from
Validator Controls • RequiredField Validator- used to check to make sure your user doesn’t leave a field blank • RegularExpressionValidator- best used to check for correct e-mail addresses, internet url, phone numbers and zip codes • RangeValidatgor- best used with dates and dates where you can select a minimum and maximum
More Validator Controls • CompareValidator- this allows you to compare a value with an operator like =,>,< • CustomValidator- this control can compare what the user is entering with the type of fields that you have in your database
Validating Your Record Input • Open the AddRecords.aspx file • Drag a RequiredFieldValidator and place aside of Enter Movie Name • Go to the properties of the RequiredFieldValidator and scroll down to ControlToValidate and type TextBox1 • Go to ErrorMessage and type Enter Movie Name • Press F5 and click the button to view how the RequiredField Validator works
Add More Validators • Drag a RequiredFieldValidator and place aside of Enter Actor Name • Go to the properties of the RequiredFieldValidator and scroll down to ControlToValidate and type TextBox2 • Go to ErrorMessage and type Enter Actor Name
More Validators • Repeat these instructions for the Actress and Director Fields • Press F5 to view and click the button