Homework Assignment #4
Many students completed this assignment in-class
in class #5 on 3/12/2007.
In class exercise
to get credit for this assignment,
demonstrate your program for the instructor in class.
starting visual studio
create web site
use template: asp.net web site
location: filesystem
language: visual basic
file: A:\web sites\website1
create dir ? yes
Add this heading: CS 206 class 5 project
pt size 24
(if missing tool bar for pt size,
view
tool bars
formatting
Start without debugging (ctrl F5)
make sure the browser shows the heading ok
File
Save all
(but floppy did not light up)
close vis studio
(floppy did light up)
remove floppy
start visual studio
open web site 1
should fail: can't access a:
insert floppy
open web site 1
now I see my heading
if the start page stays on the screen
look for default.aspx tab and click it
Look at the soln explorer
to see the files in your project
note it is under a:
Add a drop down list to your project
with elements red, blue, yellow
select the ddl
unpin the solution explorer (to give me more room)
change ID to ddlChoices
click items ...
add these items:
text value
red red5.34
blue blue6.27
green green23.91
Make the 2nd element in the list "selected"
so it appears when the program starts running.
dbl click the ddl
to open a code window
for SelectedIndexChanged for the ddl
note these 2 tabs:
default.aspx (form)
default.aspx.vb (code)
in the form add this text in 12 pt:
You selected
follow by a label
label properties
ID lblResult
Text (blank)
add code for the ddl (drop down list)
by dbl clicking the ddl
add this one line of code:
lblResult.Text = ddlChoice.SelectedItem.Text
under ddl properties
set AutoPostBack to true
Ctrl-F5 (start without debugging)
Now modify the code to put the price of the selected
color in the label.
The price is in the Value of the selected ddl item
but you must remove the text name at the start of the value
which leaves the price.
===
each value in a ddl should be unique
otherwise
after postback
the ddl will select the first item with that value
===
review some basic VB string functions
Dim sName as String
Len(sName) gives the # of chars in the string
Left(sName,5) gives the 5 left chars in the string
Right(sName,5) gives the 5 right chars in the string
Mid(sName,start,count) start is origin 1