Workshop


Quiz

1.

Imagine that you wanted to create an online multiple-choice quiz that presented the users with a question that had one correct answer. The users would be asked to choose the correct answer from a list of five. What user input Web control would be best suited for this web page?

2.

Imagine that you wanted to have the users specify what time zone they live in. What user input Web controls could be used for this task, and what ones could not be used? What user input Web control would be the best option?

3.

True or False: The DropDownList Web control can be used to allow the users to select multiple items from a list of available options.

4.

Imagine that you wanted to create a web page where users could specify how many countries they've visited from a list of 100 countries. Why would using a series of CheckBox Web control make sense here?

5.

For the example in Question 4, precisely how many CheckBox Web controls would you need to add to the ASP.NET page?

6.

What CheckBox Web control property specifies whether a check box was checked?

7.

What is the major difference between a series of RadioButton Web controls and a series of CheckBox Web controls?

8.

If you wanted to add five RadioButton Web controls to an ASP.NET web page such that users could select only one of the five resulting radio buttons, what property of each of the RadioButtons would you need to set?

Answers

1.

Because users can select precisely one option from a list of options, either a DropDownList Web control or a series of RadioButton Web controls would suffice. The best choice would likely be a series of RadioButton controls because virtually all existing online quizzes use radio buttons for the quiz user interface.

2.

This information could be provided via a text box, a series of radio buttons, or a drop-down list. A series of check boxes would not be suitable since a single user cannot live in multiple time zones. The best user input Web control for the job, though, would likely be either a series of RadioButtons or the DropDownList because the user is restricted to choosing one option from a list of possible options.

3.

False. The DropDownList Web control allows users to select only one item from a list of items.

4.

A series of CheckBox Web controls would allow users to select more than one option. Had we opted to use, say, RadioButton Web controls, the users would be able to select only one country from the list of 100.

5.

A CheckBox Web control would need to be added for each option. Because there are 100 countries from which the users can select, there would need to be 100 CheckBox Web controls on the ASP.NET page.

6.

The Checked property indicates whether a CheckBox Web control has been checked.

7.

The RadioButton Web control is designed to allow users to choose precisely one option from a list of available options. The CheckBox Web control, on the other hand, is designed so that users can choose zero or more options. Therefore, a series of RadioButton Web controls would restrict users to selecting just one option from the array of options, whereas a series of CheckBox Web controls would allow users the flexibility to choose many of the available options.

8.

RadioButton Web controls are grouped via the GroupName property. That is, each RadioButton Web control that has the same value for its GroupName is considered "grouped," and users can select only one radio button from the group. Therefore, to have five grouped radio buttons, each of the five RadioButton Web controls would need to have its GroupName property set to the same value.

Exercises

  1. The book you have in your hands is my sixth book on ASP and ASP.NET. As a shameless plug for my other books, please create an ASP.NET page that allows the user to indicate what other books of mine she has read. That is, create five CheckBox Web controls, each with its Text property set to the title of one of my five other books. In case for some odd reason you are not familiar with my other books, the five titles are (1) Sams Teach Yourself Active Server Pages 3.0 in 21 Days; (2) Designing Active Server Pages; (3) ASP.NET: Tips, Tutorials, and Code; (4) ASP.NET Data Web Controls; and (5) Sams Teach Yourself ASP.NET in 24 Hours.

    In addition to creating the five CheckBox Web controls, create a Button Web control and a Label Web control. In the Button Web control's Click event handler, count the number of books that the reader has read and emit an appropriate message. If I may so humbly suggest, if the user has read, say, four or more of my books, you might display the message "You are indeed a wonderful person", whereas if the user has yet to read any of my other books, you could emit a message like "It is absolutely imperative that you go to your nearest bookstore without delay and pick up one (or more) of Scott's books".

  2. For this exercise, create a short online quiz. Make sure the quiz has at least three questions and that each question has at least three options. Each question should have exactly one correct answer.

    After the questions, there should be a Button Web control that, when clicked, will display the user's score. If you are interested in a more difficult challenge, in addition to displaying the user's score, list next to each incorrect question the correct answer.




Sams Teach Yourself ASP. NET 2.0 in 24 Hours, Complete Starter Kit
Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
ISBN: 0672327384
EAN: 2147483647
Year: 2004
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net