Microsoft ASP.NET Web Matrix Starter Kit (Bpg-Other)

You ve now created a quotations page that will show a different quotation every time the page is displayed. But you still haven t seen any quotations! It s time to test the page to see how your quotations look in the page.

Run the quotations page

  1. Press F5 to run the page.

  2. Verify that a quotation does appear.

  3. Click the Show Another Quote button in the browser to run the page again. You should see a different quotation. (Because you re working with random numbers, it s statistically possible that you ll see the same quotation, of course.)

  4. Click the button several more times. You should see a selection of quotations.

Depending on how many quotations your  quotations.txt file contains, it might not be obvious that you re getting a true random selection. I recommend that you click the button until you re satisfied that you re getting different quotations, including both the first and last quotations in the file.

If your quotations aren t showing up as they should, check the following:

We ve accomplished what we set out to do read quotations from a text file and display a randomly selected quotation on the page. The  RandomQuotes.aspx page works, but it can work more efficiently. In the next section, I ll show you a technique for improving the page.

Категории