Exercise: Using properties to validate min and max ages

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend the Wise Owl course listed below!

Category ==> ASP.NET webforms - VB  (27 exercises)
Topic ==> Creating properties in VB  (1 exercise)
Level ==> Average difficulty
Course ==> ASP.NET WebForms - VB
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Create a new website, and add the 4 files from the folder above into it, then create a new web page called frmRequest, based on the yoda.master master page.

Create 3 properties (see below) and code so that the form allows you to choose your ideal date's age range:

ASP.NET 4.0 - Visual Basic exercise - Creating properties in VB (image 1)

If you leave either age limit blank, or input an invalid value, you get an error

The properties that you should create are as follows:

  • MinimumAge, giving the minimum age typed in (or -1 if this isn't a valid integer)
  • MaximumAge, giving the maximum age typed in (or -1 if this isn't a valid integer)
  • ErrorMessage, giving the error message to display

For each property, think whether it should be ReadOnly, ReadWrite or WriteOnly.

Choose your ideal date's age range - you should see a confirmation message:

ASP.NET 4.0 - Visual Basic exercise - Creating properties in VB (image 2)

This person has catholic tastes ...

Save and close any files that you have open.

This page has 0 threads Add post