0% found this document useful (0 votes)
56 views3 pages

BSC in Computing Comp222 Internet Programming I Lab Practice 2: Web Server Controls

This document describes a lab practice assignment to create a web project in Visual Basic using various web server controls. It lists the controls to be used, such as text boxes, radio buttons, check boxes, and drop down lists. It provides code examples for implementing drop down lists, list boxes, and check box lists. It outlines four parts to the assignment: 1) create the web project, 2) add an event handler for the submit button, 3) maintain scroll position when toggling a check box, and 4) modify a list box to allow multiple selections and display the selected items.

Uploaded by

WaiWengLo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views3 pages

BSC in Computing Comp222 Internet Programming I Lab Practice 2: Web Server Controls

This document describes a lab practice assignment to create a web project in Visual Basic using various web server controls. It lists the controls to be used, such as text boxes, radio buttons, check boxes, and drop down lists. It provides code examples for implementing drop down lists, list boxes, and check box lists. It outlines four parts to the assignment: 1) create the web project, 2) add an event handler for the submit button, 3) maintain scroll position when toggling a check box, and 4) modify a list box to allow multiple selections and display the selected items.

Uploaded by

WaiWengLo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

BSc in Computing

COMP222 Internet Programming I


Lab Practice 2: Web server controls
Part 1: Create a web project named AdventureWorks. Relevant material can be found
at O:\Calana\COMP222\Exercise\Lab2
Web server controls involved:

TextBoxes
RadioButtons
CheckBox
DropDownList

RadioButtonList
CheckBoxList
ListBox
Button

<asp:DropDownList ID="ddlState" runat="server">


<asp:ListItem Value="AL">Alabama</asp:ListItem>
<asp:ListItem Value="AK">Alaska</asp:ListItem>
<asp:ListItem Value="CA">California</asp:ListItem>
<asp:ListItem Value="CT">Connecticut</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlCategory" runat="server">
<asp:ListItem>Bikes</asp:ListItem>
<asp:ListItem>Components</asp:ListItem>
<asp:ListItem>Clothing</asp:ListItem>
<asp:ListItem>Accessories</asp:ListItem>
</asp:DropDownList>
<asp:ListBox ID="lbSubcategory" runat="server">
<asp:ListItem>Brakes</asp:ListItem>
<asp:ListItem>Handlebars</asp:ListItem>
<asp:ListItem>Chains</asp:ListItem>
<asp:ListItem>Cranks</asp:ListItem>
<asp:ListItem>Bottom Brackets</asp:ListItem>
<asp:ListItem>Tires</asp:ListItem>
</asp:ListBox>
<asp:CheckBoxList ID="cblAreas" runat="server">
<asp:ListItem>Biking</asp:ListItem>
<asp:ListItem>Scuba Diving</asp:ListItem>
<asp:ListItem>Gaming</asp:ListItem>
<asp:ListItem>Mountain Climbing</asp:ListItem>
<asp:ListItem>Web Surfing</asp:ListItem>
</asp:CheckBoxList>

Image
Hyperlink

ID="ddlState"

ID="rblAge"
ID="cblAreas"
ID="ddlCategory"

ID="CategoryLabel"

ID="lbSubcategory"

ID=" SubCategoryTextBox"; remember

ID="cbDisplayPhoto"

to set ReadOnly="true"

ID="tdAddress"; and remember to set runat="server"

<td id="tdAddress" runat="server" style="width:200px">


This is what AdventureWorks Order Form will look like when it is finished.
Part 2:
1. Write an event handler to handle the Click event of the Submit button to display
2.
3.
4.

the summary.
Write an event handler to handle the CheckChanged event of the last checkbox to
control the display of the image or not.
On toggling the checkbox cbDisplayPhoto to display or hide the photo, the
scroll position of the page should be maintained on postback.
Modify the listbox lbSubcategory to allow multiple select. Handle the display
of the content of the chosen items in this listbox properly.

BSc in Computing
COMP222 Internet Programming I
Lab Practice 2 Part 2 ~ Suggested Answers
3. On toggling the checkbox cbDisplayPhoto to display or hide the photo, the
scroll position of the page should be maintained on postback.
At Page directive (Go to the Source page of the aspx page, line 1),
set MaintainScrollPositionOnPostback="True"
4.

Modify the listbox lbSubcategory to allow multiple select. Handle the display
of the content of the chosen items in this listbox properly
4.1 For aspx page:
First, set SelectionMode=Multiple for the listbox lbSubcategory
Set TextMode="MultiLine" for the Textbox (ID="SubCategoryTextBox") to
display the content of the chosen Subcategory
4.2 For aspx.vb code-behind file, comment out the line
SubCategoryTextBox.Text = lbSubcategory.SelectedValue
Dim Subcategory As String = String.Empty
this is necessary to prevent run-time error
when no choices have been made from lbSubcategory
Dim li As ListItem
For Each li In lbSubcategory.Items
If li.Selected Then
Subcategory += li.Text + vbLf
End If
Next
SubCategoryTextBox.Text = Subcategory

You might also like