22.05.2017 Views

BIS 450 DeVry All Week iLabs

Create successful ePaper yourself

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

tnCalculate_Click(. . . ) and End Sub statements in the code-behind file. Notice that the code is incomplete. After<br />

pasting in this code, the code-behind file should look like this:<br />

3. Based on the specifications provided by Dr. Dinewell (listed in the scenario at the top of these lab instructions), write<br />

the additional statement needed in the Else clause to calculate the BMR for men. Use the formula for women provided<br />

in the function as a model.<br />

Hint: You only need to replace the “‘TO DO:” line with the men’s BMR values.<br />

4. Save your work so far.<br />

STEP 4: Add Input Validation<br />

1. Return to editing the CalNeeds.aspx Web form in Design View.<br />

2. Drag a RequiredFieldValidator control from the Validation section of the Toolbox and place it on the form just to the<br />

right of the txtHeight TextBox. Set its properties as follows to ensure that the user enters a value for height:<br />

Property Setting<br />

ControlToValidate txtHeight<br />

Display Dynamic<br />

ErrorMessage You must enter your height in inches.<br />

3. Drag a RangeValidator control from the Validation section of the Toolbox and place it on the form to the right of the<br />

RequiredFieldValidator you added in the previous action. (It’s OK if the validators wrap onto the next line in the editing<br />

window display.) Set the RangeValidator’s properties as follows to ensure that the user enters a height value that is a<br />

type Double (that is, a decimal number,) that is in the range of 48 to 84 inches:<br />

Property Setting<br />

ControlToValidate txtHeight<br />

Display Dynamic<br />

ErrorMessage Height must be a decimal number between 48 and 84 inches.<br />

MaximumValue 84<br />

MinimumValue 48<br />

Type Double<br />

Here is what part of your form should look like with both validation controls in place (what you see may vary depending<br />

on the width of your editing window):<br />

4. In a similar way, place a RequiredFieldValidator and a RangeValidator to the right of the txtWeight TextBox, and set<br />

their properties to ensure that the user enters a value for weight, and that value is a type Double (decimal number) that<br />

is between 50 pounds and 500 pounds. Compose your own reasonable error messages for these validators.<br />

5. Place a RequiredFieldValidator and a RangeValidator to the right of the txtAge TextBox, and set their properties to<br />

ensure that the user enters a value for age, and that value is a type Integer (whole number) that is between 18 and<br />

120. Compose your own reasonable error messages for these validators.<br />

6. Save your work.<br />

STEP 5: Test, Capture Screenshot, and Submit<br />

1. To test the Calorie Needs calculator, in the Solution Explorer window, right-click on CalNeeds.aspx and select View<br />

in Browser. If you experience problems viewing your page, perform the following:<br />

• In the Solution Explorer, right-click on your FTP address and select Property Pages.<br />

• Under the Start Options tab, make sure the Base URL is set to include the full HTTP address listing (example only:<br />

HTTP://bisweb.devry.edu/YourCourseFolder/YourPersonalFolder).<br />

2. Enter some different values for the various inputs into the calculator, click Calculate Calorie Needs, and check the<br />

results. Some test values you might want to try are:

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

Saved successfully!

Ooh no, something went wrong!