Homework Assignment #9
Most students completed this in class #8 on 4/9/2007.
- copy halloween2005 dir from
U:\cs206-1\halloween2005
to your floppy
- change the dir name to: hmwk9
- copy the files dir from
U:\cs206-1\Files
to your floppy
- start Visual Studio 2005
in solution explorer
expand App_code
dbl click: ProductIO.vb
find a line like this:
Dim CategoryStream As New
FileStream("D:\proj\2007\rancho\s2007spr\206\murach\Files\Categories.dat",
and change the pathname to the floppy like this:
FileStream("A:\Files\Categories.dat",
do the same for the other file.
In the soln explorer,
right click: order.aspx
set as start page
start without debugging
and the application should start ok.
review p 88 on how to add another form to your project.
review p 93 on what code changes from one form to another.
We will use the redirect method,
even though it is a little less efficient,
because it is more user friendly
in that that url reflects the new page.
Next we will replace the current checkout code
(which just prints a msg it is not implemented)
to go to a new form
which says not implemented.
and has a button to go back.
close the browser that was running the application.
in the soln explorer
right click the project name (a:\hmwk9)
add new item
make sure the template selected is: web form
change the name to: checkout.aspx
make sure this is checked: place code in separate file
bring up order.aspx
right click the banner image
click copy
bring up checkout.aspx
right click
click paste
so checkout.aspx has the same Halloween banner
Under the banner
add a message that the checkout screen has not yet been implemented.
put this in 16 pt font of type ariel.
Change the checkout button
to go the checkout screen.
In the checkout screen,
add 1 button
to go to the order screen.
Run your program,
make sure you can go back and forth
between the order screen and the checkout screen.
Challenge: (not graded)
add a 2nd button
to go the the shopping cart screen
but keep this grey'ed out
until there is something in the cart
and it is ok to go there.
Review page 100 on validation controls.
in your checkout screen.
add txtBox1
add a "Required field validator"
(review page 102 on this validator)
in the properties for that validator
set ControlToValidate to be txtBox1
set Text property to: This cannot be blank
Test your program
you should not be able to leave the checkout screen
if the text box is blank.
Note: one student seemed to set everything correctly
but the validator did not display the error
and did not prevent the button from working.
adding a new button solved the problem.
review page 102 on the compare validator
add a 2nd validator to your screen: the compare validator
control to validate: txtBox1
operator: greater than
value to compare: 5
text: value must be greater than 5