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
-
Press F5 to run the page.
-
Verify that a quotation does appear.
-
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.)
-
Click the button several more times. You should see a selection of quotations.
Depending on how many quotations your
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
|