Testing the Page


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:

  • Make sure the  RandomQuotes.aspx file and the  quotations.txt file are in the same directory.

  • Make sure you added an extra backslash character (\) in this line:

    srQuotes = New System.IO.StreamReader(path & "\ quotations.txt")
  • Make sure that each quotation is on a single line in the text file (no wrapping) and that there aren t blank lines at the end of the file.

  • Check that you don t have the file open in your text editor if the StreamReader object can t get exclusive access to a file, the open process fails.

  • Make sure the quotation and author name are delimited with the correct character.

  • If you changed the code from splitting the line to simply converting the pipe character to another character, make sure you commented out the line-splitting code.

  • 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.




    Microsoft ASP. NET Web Matrix Starter Kit
    Microsoft ASP.NET Web Matrix Starter Kit (Bpg-Other)
    ISBN: 0735618569
    EAN: 2147483647
    Year: 2003
    Pages: 169
    Authors: Mike Pope
    BUY ON AMAZON

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