- Specifying the Design Requirements
- Creating the User Interface
- Writing the Source Code for the ASP.NET Web Page
- Testing the Financial Calculator
- Summary
- Q&A
- Workshop
Testing the Financial Calculator
Now that we have completed the HTML and source code portions of our ASP.NET Web page, it's time to test. First make sure that you have saved the ASP.NET Web page since entering the source code in Listing 3.1. Next view the ASP.NET Web page through your browser. When first visiting the page, you should see three empty textboxes and the Compute Monthly Cost button, as shown in Figure 3.11.
Figure 3.11 When the ASP.NET page is first visited, three textboxes await user input.
Now go ahead and enter some values into the textboxes and then click the Compute Monthly Cost button. When this button is clicked, the monthly cost is displayed beneath the textboxes and button, as shown in Figure 3.12.
Figure 3.12 The output of the financial calculator is displayed when the Button is clicked.
Testing Erroneous Input
Part of testing is not only testing expected inputs but also testing unexpected ones. For example, what will happen if the user enters into the Mortgage Length textbox a value of "Jisun"? Obviously, this is not a valid number of years. Entering such an erroneous value will cause a run-time error, as shown in Figure 3.13.
Figure 3.13 A run-time error will occur if the input is not in proper format.
Errors such as those shown in Figure 3.13 are an eyesore. Rather than displaying such error messages when the user enters erroneous input, it would be better to display a simple error message next to the textbox(es) with erroneous input, explaining that the input is not in the right form.
The process of ensuring that user input is in the correct format is known as input validation. Fortunately, input validation is incredibly easy with ASP.NET. We'll examine ASP.NET's input validation features in Hour 12, "Validating User Input with Validation Controls."
NOTE
Earlier in this hour we discussed the importance of planning the user interface and functionality of an ASP.NET Web page prior to creating the page. Not only is it important to plan how the ASP.NET Web pages should work, but it is also important to plan on how to ASP.NET Web page should behave when things don't necessarily go according to plan.